Hi
How to validatethat textbox should accept only alphabets using javascript.
Textbox Name : txtcode
Thanks
Validate
2 Answers
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
Benjamin KemnerRank #7,492 · 240 reputationPosted Jul 19, 2011, 5:00 AM EDT
I think it's possible with the RegularExpressionValidator if you enable the "EnableClientScript"-Property. check this EnableClientScript="true" ControlToValidate="txtcode" ValidationExpression="[A-Za-z]" Display="Static" ErrorMessage="String isn't alphabet">Jiteendra SampathiraoRank #585 · 4.1K reputationPosted Jul 19, 2011, 5:06 AM EDT
function validate()
{
var good = false;
var chk_name=/^[A-Za-z ]$/;
if(document.form1.ENAME.value == "")
{
window.alert("ENAME field should not be blank");
document.form1.ENAME.focus();
}
else
{
if (!ck_name.test(document.form1.ENAME.value))
{
window.alert("The Ename Field cannot contain special characters");
document.form1.ENAME.value="";
document.form1.ENAME.focus();
}
}
return (good);
}
hope this help you.......