Regular Expression Validator and RequiredFieldValidator ???

  • Thread starter Thread starter S.Kartikeyan
  • Start date Start date
S

S.Kartikeyan

I have the following problem.
I am using the follwing Regular Expression validator(REV) with validator expressions
^[0-9]{1,2}$
^[a-zA-Z0-9]{3,20}$
The idea of the first exp is 1 or 2 digits
the idea of second expression is username between 3 and 20 chars

When the user enters characters other than the specified REVs are working.
But if the user leaves the textbox without entering anything
Page.IsValid is true which indicates it is not performng any validation.

I read that {n,m} syntax in .net regular expressions is min(n)-max(m)
in the documentation.

Should i also use ReguiredFieldValidator
in addition to regular expression validator

any one facing the same problem.

where is the mistake in me or in .net
 
Thanks For your help.
I was wondering where is the mistake.
Microsoft should have designed it the otherway which is more intuitive.

S.Kartikeyan

Martin Dechev said:
Hi, S.Kartikeyan,

Yes, you should use a combination of RegularExpressionValidatior and a
RequiredFieldValidator in order to prevent the user from leaving the
associated control blank.

It is mentioned in the Note in the Remarks section:

http://msdn.microsoft.com/library/e...trolsRegularExpressionValidatorClassTopic.asp

Greetings
Martin
S.Kartikeyan said:
I have the following problem.
I am using the follwing Regular Expression validator(REV) with validator expressions
^[0-9]{1,2}$
^[a-zA-Z0-9]{3,20}$
The idea of the first exp is 1 or 2 digits
the idea of second expression is username between 3 and 20 chars

When the user enters characters other than the specified REVs are working.
But if the user leaves the textbox without entering anything
Page.IsValid is true which indicates it is not performng any validation.

I read that {n,m} syntax in .net regular expressions is min(n)-max(m)
in the documentation.

Should i also use ReguiredFieldValidator
in addition to regular expression validator

any one facing the same problem.

where is the mistake in me or in .net
 
Back
Top