all groups > asp.net > february 2004 >
You're in the

asp.net

group:

RegularExpressionValidator?


Re: RegularExpressionValidator? Craig Deelsnyder
2/8/2004 9:05:32 PM
asp.net:
[quoted text, click to view]

Validators normally aren't enabled when something is left blank. Why
that decision was made (especially for regex validators) I'll never
know. Slap a RequiredFieldValidator on the field as well and all shall
function properly (if not with a little extra maintenance on your part).

--
Craig Deelsnyder
RegularExpressionValidator? DC
2/8/2004 9:43:22 PM
I have this snippet:

<tr>
<td align="left">E-mail</td>
<td>
<asp:TextBox id="txtEmail" runat="server"
MaxLength="100"></asp:TextBox>&nbsp;
<asp:RegularExpressionValidator id="revEmail" runat="server"
ErrorMessage="Enter a valid e-mail address"
ControlToValidate="txtEmail"

ValidationExpression="\b[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z0-9._%-]{2,4}\b">
</asp:RegularExpressionValidator>
</td>
</tr>

My question is why this regular expression is not invoked if I leave the
textbox blank?
My understanding is blank entry is not met the requirement of that regular
expression.

Am I missing something here?

- DC

Re: RegularExpressionValidator? Earl Teigrob
2/8/2004 11:07:00 PM
I personally like the way Nicrosoft did that because you get two seperate
messages, one for [Required] and one for [Invalid].

[quoted text, click to view]

Re: RegularExpressionValidator? Scott M.
2/9/2004 1:18:21 AM
It makes perfect sense to me, IF you enter a value, it will be validated.
It's not a RequiredRegularExpressionValidator after all, it's just a
RegularExpressionValidator.


[quoted text, click to view]

AddThis Social Bookmark Button