solo numeros en campo de texto javascript


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



Copy this code and paste it in your HTML
  1. <HTML>
  2. <HEAD>
  3. <SCRIPT language=Javascript>
  4. <!--
  5. function isNumberKey(evt)
  6. {
  7. var charCode = (evt.which) ? evt.which : event.keyCode
  8. if (charCode > 31 && (charCode < 48 || charCode > 57))
  9. return false;
  10.  
  11. return true;
  12. }
  13. //-->
  14. </SCRIPT>
  15. </HEAD>
  16. <BODY>
  17. <INPUT id="txtChar" onkeypress="return isNumberKey(event)" type="text" name="txtChar">
  18. </BODY>
  19. </HTML>

URL: http://www.cambiaresearch.com/c4/029c978b-aac5-472e-97a8-95b256f5febd/How-Can-I-Use-Javascript-to-Allow-Only-Numbers-to-Be-Entered-in-a-TextBox.aspx

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.