In case anyone is looking for a solution to the above question: you can use html/javascript snippet and add a class to the desired textbox and use the same class to listen to the keypress event and suppress any key other than numbers as below:
$(".phone").keypress(function (event) {
var keycode = event.keyCode ? event.keyCode : event.which;
if (keycode < 48 || keycode > 57) {
return false;
}
});
Full list of keycodes can be found on google!
Hope this helps.
Hi Shaan,
Please check if input mask is what you're looking for.
Hi Shaan Ahmed,
Why not just try a regex to allow only numbers and use isMatch to validate and give feedback ? I think this is the easiest and smartest way to do it.
Regex:
^[0-9]*$
Regards,
Sharad R K