Validation Control - Force user to enter string not number

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
 
S

Stephan Bour

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

Stephan.
 
M

Michael

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top