Posted By

sekihin on 03/10/09


Tagged

javascript format


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jamesming


Convert Currency To Number


 / Published in: JavaScript
 

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <TITLE> getNumber Test Document </TITLE>
  5. <script type="text/javascript">
  6. <!--
  7. function getNumber(value){
  8. num = 0;
  9. kugiri = new RegExp(",", "g");
  10. num = value.replace(kugiri, "");
  11. num = num.replace('\\', "");
  12. num = Number(num);
  13. return num;
  14. }
  15. function btn_click() {
  16. value=document.form1.text1.value;
  17. document.form1.text2.value=getNumber(value);
  18. }
  19. / -->
  20. </script>
  21. </HEAD>
  22.  
  23. <BODY>
  24. <form method="post" action="" name="form1">
  25. <input type="text" name="text1" value="123,456.789"><br>
  26. <input type="text" name="text2"><br>
  27. <input type="button" name="btn" onclick="btn_click()" value="button">
  28. </form>
  29. </BODY>
  30. </HTML>

Report this snippet  

You need to login to post a comment.