RegularExpression validator that does not allow blanks

  • Thread starter Thread starter John Hoge
  • Start date Start date
J

John Hoge

I have a regex "^\d{5}$" that does not allow blanks, but the
RegularExpressionValidator does not fire for empty fields. Is there a
way to make it do so? I would rather not include a separate
RequiredValidator for reasons of brevity and neatness.

Thanks,
John
 
Hi John,

Unfortunately, you will need both a RequiredFieldValidator AND a
RegularExpressionValidator for your purposes.

Here's the word from the MSDN Library:
"Note: If the input control is empty, no validation functions are called
and validation succeeds. Use a RequiredFieldValidator control to prevent
the user from skipping an input control."

You can find the full article here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
ml/cpconregularexpressionvalidatorcontrol.asp

HTH,
Chris [MSFT]

--------------------
 
Back
Top