Posted By

lromak on 01/11/13


Tagged

form html


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Abiotic


Remove $ from HTML form on submit


 / Published in: JavaScript
 

Removes $ from HTML form post, allows only number and decimal points. Has $ display in field but disappear when onfocus.

  1. The javascript allows only number and decimal points:
  2.  
  3. <SCRIPT language=Javascript>
  4. <!--
  5. function isNumberKey(evt)
  6. {
  7. var charCode = (evt.which) ? evt.which : event.keyCode;
  8. if (charCode != 46 && charCode > 31
  9. && (charCode < 48 || charCode > 57))
  10. return false;
  11.  
  12. return true;
  13. }
  14. //-->
  15. </SCRIPT>
  16.  
  17. The blank amount to pay field displays the $ until the field is active:
  18.  
  19. <input type="num" name="charge_total" value="$" onfocus="this.value=''" onkeypress="return isNumberKey(event)" >

Report this snippet  

You need to login to post a comment.