Only Numbers In An Input


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

N'autorise que les chiffres (avec , ou . ou négatifs) dans un input


Copy this code and paste it in your HTML
  1. $("#inputTarif").keypress(function(event){
  2. var charCode = (event.which) ? event.which : window.event.keyCode;
  3. if (charCode <= 13) { return true;}
  4. else {
  5. var keyChar = String.fromCharCode(charCode);
  6. var Exp = new RegExp("[0-9,.-]");
  7. return Exp.test(keyChar);
  8. }
  9. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.