Remove $ from HTML form on submit


/ Published in: JavaScript
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.