Regular expression in jquery for validating only alphabetic characters.
How to validate a TextBox to accept only alphabetic characters in jquery?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anil KumarPosted Jun 1, 2012, 1:32 AM
$(function(){
$('input [id$=txtAlphabetic]").keyup( function(e){
if( this.value.match(/[^a-zA-Z0-9]/g) )
{
//return false; OR replace entered char with nothing but ''. it is upto you.
e.preventDefault();
}
});
});
If you are using jQuery.validate then add your own function to jQuery. Refer: http://stackoverflow.com/questions/5155492/jquery-validation-for-alphabets