Click here to Skip to main content
14,732,936 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
so that a text box can accept only alphabetics
Posted

u can make use f regular expression ^[a-zA-Z]$....compare it with the text box value....if u r in asp, u can use regular expression validator tool or else jst use regex property in the code behind.
   
add the belowline in page_load event
textbox.Attributes.Add("onkeypress","return EnsureAlphabets();");

in aspx page add the javascript


function EnsureAlphabet()
{ var k=window.event.keyCode;
if(!((k>64&&k<91)||(k>96&&k<123)||k==32||k==45||k==46))
{ window.event.returnValue=false;
}
}
   
hi ... above answer is write but u also used ajax control Just download ajax controls lots of control are available just search and download , and use , if u want to used , i used ajax controls .........
   

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