how to restrict......

A

atif

I hav a prob with the textfield i want to restrict this field so that
only integer values should b entered e.g 0-9 n no english or special
characters should b entered in the text field
 
H

Hermit Dave

use a regular expression validation control ?

with expression like
\d{5,20}


or you could also use range validator...

specify it as integer or double and specify the range and control you wish
to check...

--
Regards,

HD

atif said:
I hav a prob with the textfield i want to restrict this field so that
only integer values should b entered e.g 0-9 n no english or special
characters should b entered in the text field
 
D

Dan Brussee

What I think you are asking for is a masked edit text box where it
will only allow the digit characters to be entered. This action would
be required on the client side - not on the server side, so ASP.NET is
not involved. As stated in another response, you could do validation
using regular expression, javascript, etc on the client or after it
has been submitted on the server.

However, there are cases where what you ask CAN be done on the client.
It would require some fairly complex Javascript code and would very
prone to failures on certain versions of browser. Although it seems
reasonable to do, I say that it is easier all around - including for
the user - if you just let them type what they want and validate it
for correctness. Im sure you will need to validat anyway to be sure a
value exists, etc. Remember, you are dealing with a very limited
environment of a browser. I always hated masked input fields anyway,
but that's just me :)

Dan


On 13 Jan 2004 01:17:35 -0600,
I hav a prob with the textfield i want to restrict this field so that
only integer values should b entered e.g 0-9 n no english or special
characters should b entered in the text field
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top