Why is LengthValidator a RequiredValidator at the same time ?

May 22, 2009 at 9:44 AM

Hi,

 

I'd like to set up a validator that checks if a field is either blank or contains exactly 14 characters. Unfortunately a LengthValidator with MinLength and MaxLength="14" complains if the textbox is left blank.

 

I thought maybe the IsRequired attribute could help me but it seems to have no effect (at least, it doesn't make the field optional).

 

Why should a LengthValidator have the additional behavior of a RequiredFieldValidator as soon as MinLength is specified ? Is there a way to get around this ?

 

Thx