How to validate non-required fields?

  • Thread starter Thread starter Tien
  • Start date Start date
T

Tien

Hi,

By default, all controls must have a RequiredField control in order to
use more complex validation control e.g. RangeValidator, so how can I
use validation controls with non-required fields?

Thanks,
 
Hi,

If there is some input in the control it will be validated against the
RangeValidator with or without RequiredFieldValidator. If there is no input
the RangeValidator (or RegularExpressionValidator) will judge the input as
valid, that's why one normally uses it in combination with a
RequiredFieldValidator. RequiredFieldValidator only ensures that there is
input. Validators work independant from each other.

Hope this helps
Martin Dechev
ASP.NET MVP
 

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

Back
Top