Wednesday, October 9, 2013

Jquery textbox accept only alpha characters

HTML


Jquery

$('#alphaonly').bind('keypress', function (event) { var regex = new RegExp("^[a-zA-Z]+$"); var key = String.fromCharCode(!event.charCode ? event.which : event.charCode); if (!regex.test(key)) { event.preventDefault(); return false; } });

No comments:

Post a Comment