Visual Studio .NET - validating name in asp net
Asked By jeccinta jeccinta on 13-Feb-06 12:27 AM
hi,
Am working in asp.net..I need to do validaion for name in such a way that it shouldn't accept numbers.So on click of submit button if the name has any numbers it should show an pop up as no numbers in name field..
can u please tell me how to do this....
use regular expression validator
Asked By dejawoo Pi on 13-Feb-06 12:36 AM
www.regexlib.com u can find regular expression that suits to your needs. If u want to make it work as popup u may use validation summary. set the display property of regular expression validator to NONE , showsummary property of validation summary control to FALSE and showmessagebox property of validation summary to TRUE
Regular Expression
Asked By F Cali on 13-Feb-06 12:38 AM
You can use a regular expression validator for your text box. You can try to use the following regular expression:
"^[a-z][A-Z]$"
This will only accept the letters a to z both in uppercase or lower case.
RE : validating name in asp net
Asked By Nadeem Khawar on 13-Feb-06 12:43 AM
Hi,
What you can do is either use asp.net validator control (they have a down side that they only run on IE and secondly they will not show a pop up) or you can use javascript for validation.
For your requirement I will recommend using javascript. For validating in javascript what you should do is attach javascript to submit button. If your submit button is server control you can attach javascript click event like this
ButtonName.Attributes.Add(EVENT NAME, SCRIPT OR JAVASCRIPT METHOD NAME)
In the javascript function you can use the following regular expression
var invalidCharactersRegExp = /[^a-z\d ]/i;
var isValid = !(invalidCharactersRegExp.test(string) );
return isValid;