Click here to Skip to main content
12,950,268 members (63,668 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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.ns819
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 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]+$"
Member 12222516 18-Jan-17 2:47am
   
No comment
Member 12222516 18-Jan-17 2:47am
   
_gbg_gb
pck.ns 4-May-12 6:53am
   
sorry for first but now its working...............thanx
VJ Reddy 4-May-12 7:07am
   
You're welcome and thank you for accepting the solution and response.
Member 12222516 18-Jan-17 2:46am
   
b
Member 12222516 18-Jan-17 2:46am
   
gfg
Sandeep Mewara 4-May-12 10:00am
   
Good answer. 5!
VJ Reddy 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  
Comments
pankaj kumar priyadarshi 20-Oct-15 3:05am
   
I want Stop special char,spaces and digits or allow only hindi and english chars
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)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,829
CHill60 3,460
Maciej Los 2,953
Jochen Arndt 1,975
ppolymorphe 1,820


Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 25 Feb 2016
Copyright © CodeProject, 1999-2017
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