How to validate non-required fields?

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,
 
M

Martin Dechev

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

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top