how to restrict......

  • Thread starter Thread starter atif
  • Start date Start date
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
 
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
 
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
 
Back
Top