Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all...
i have 3 textboxes in a form...these 3 testbox should only accept alphabets...
if any numeric characters entered means it will show a messagebox like only albhabets are allowed..i am new to javascript...so i dont knw how to the coding part....can anyone plss explain me how to do this.....?
Posted
Updated 16-Feb-12 18:42pm
v2
Comments
_Maxxx_ 17-Feb-12 0:22am    
You've posted this as a C# question but say you are new to javascript. Is this an ASP.Net page ? If so, are you using MVC or 'plain old' ASP.NET?
amaljosep 17-Feb-12 0:40am    
this is an asp.net page..i am using the plain old asp.net

1 solution

SQL
function isAlphaOrParen(str) {
  return /^[a-zA-Z()]+$/.test(str);
}
Modify the regexp as needed:

/^[a-zA-Z()]*$/ - also returns true for an empty string
/^[a-zA-Z()]$/ - only returns true for single characters.
/^[a-zA-Z() ]+$/ - also allows spaces




<script type = "text/javascript">

function isAlpha(keyCode)
{
   return ((keyCode >= 65 && keyCode <= 90) || keyCode == 8 )
}

</script>
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900