Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
allow only alphabets and spaces in textbox from codebehind in asp.net C#
---------------------------------

Hi friends,
I have a textbox on my webpage, I want to allow only alphabets and spaces in this textboxes.

I dont want to use Javascript Code.
Please can you give the solution from code behind.

Thanks.
Posted
Updated 25-Jan-17 22:00pm
Comments
King Fisher 19-Mar-15 6:00am    
What about Filtered Textbox Extender?

The only way to do this with out javascript is using the Pattern attribute.

But this has limited browser support.

HTML input pattern Attribute[^]

Alphas only would look something like this:

XML
<input type="text" pattern="[A-Za-z\\s]*" />


Unless you have 100% control over the browser being used I strongly suggest you develop a Javascript method for this.
 
Share this answer
 

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