/ Published in: jQuery

Use:
$(document).ready(function(){
$("#input").forceNumeric();
});
$(document).ready(function(){
$("#input").forceNumeric();
});
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
jQuery.fn.forceNumeric = function() { $(this).keydown(function(event){ if( event.keyCode == 46 || event.keyCode == 8 || (event.keyCode < 41 && event.keyCode > 36) || (event.keyCode < 58 && event.keyCode > 47) || (event.keyCode < 106 && event.keyCode > 94) ){ }else{ event.preventDefault(); } }); }
Comments
