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]

--------------------
 

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