could you please tell me how to make a input field in which user only enter numbers using regex.i am able to do using ascii values .But I need to do this using regular expression
here is my code http://jsfiddle.net/HkEuf/6100/
$(document).ready(function () {
//called when key is pressed in textbox
$("#quantity").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
var BlkAccountIdV = $('#quantity').val();
var re = /[^0-9]/g;
if ( re.test(BlkAccountIdV) ){
console.log("=====")
errorflag=1;
}else {
console.log("==tt===")
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
/*if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}*/
});
});
Thnaks