Why RangeValidator and RegularExpression cannot validate nullvalues??

M

Mark Fitzpatrick

It's their job to ensure that a value passed to them is valid. Since no
value is passed, how can it be invalid? It's not their job to ensure that
there is data in a field, that's the job of the RequiredField Validator.
This let's you do things like have an optional email address field that
checks the formatting through a regular expression validator. Since they
don't have to fill it in, you wouldn't want an error reported to them about
incorrect email address. If you don't want it optional, you place a
requiredfield validator there. Then it will always make sure that first,
there's a value there, then second, the value matches the range or regular
expression validator.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top