Regular expression in jquery for validating only alphabetic characters.
How to validate a TextBox to accept only alphabetic characters in jquery?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Anil KumarRank #367 · 6.8K reputationPosted May 31, 2012, 9:32 PM EDT
$(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