Validation Control - Force user to enter string not number

  • Thread starter Thread starter Andy Eshtry
  • Start date Start date
A

Andy Eshtry

I need to validate a textbox control using the validation control so that
user can enter only string (character) type not numbers
I used comparevalidator and set the "Operator" property to "Datatype check"
and "Type" property to "String" but I can enter numbers and this is not I
want.
Also I used Regular expression validator and set the validation expression
to "\w {n}" means any number of characters or \w {n} [a-z] [A-Z] means only
characters between A-Z and a-z but I can enter number :(.

Please help.

Best Regards
Andy Eshtry
 
This should work with a regular expression validator:
ValidationExpression="^[A-Za-z]{1,}$"

Stephan.
 
Are you trying to physically prevent a number from appearing in the textbox?
That would seem silly to me to do, but if you must, you'll have to use your
own JavaScript to catch each keystroke. Client side validators will trigger
the error, but the user still has the freedom to enter whatever they want,
until they try and submit the form.
 
Back
Top