Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET
can anybody tell me how to validate name textbox with regular expression validation.
so that it can take only alphabets and space
Posted 4-May-12 0:18am
pck.ns546
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The following regular expression can be used for the above purpose
^[a-zA-Z\s]+$
  Permalink  
Comments
VJ Reddy at 4-May-12 6:32am
   
It works. You can test it here http://regexhero.net/tester/
In C# either use @"^[a-zA-Z\s]+$" or "^[a-zA-Z\\s]+$"
pck.ns at 4-May-12 6:53am
   
sorry for first but now its working...............thanx
VJ Reddy at 4-May-12 7:07am
   
You're welcome and thank you for accepting the solution and response.
Sandeep Mewara at 4-May-12 10:00am
   
Good answer. 5!
VJ Reddy at 4-May-12 10:15am
   
Thank you, Sandeep.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Here u can use this
 
^[a-zA-Z][a-zA-Z\\s]+$
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You Can try this
 

^[a-zA-Z][a-zA-Z\\s]+$
 
or go to Link:-
 
validation expression for name in regular expression validation[^]
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 7 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100