I am creating a web page where I have an input text field in which I want to allow only numeric characters like (0,1,2,3,4,5...9) 0-9.
How can I do this using jQuery
Inline:
Unobtrusive style (with jQuery):
$('input[name="number"]').keyup(function(e) { if (/\D/g.test(this.value)) { // Filter non-digits from input value. this.value = this.value.replace(/\D/g, ''); } });