Posted By

sebabarre on 10/09/14


Tagged

form javascript html input jquery


Versions (?)

Only Numbers In An Input


 / Published in: jQuery
 

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

  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  

You need to login to post a comment.