Re: RegularExpressionValidator?

From: Craig Deelsnyder (cdeelsny_at_NO_SPAM_4_MEyahoo.com)
Date: 02/09/04


Date: Sun, 08 Feb 2004 21:05:32 -0600

DC wrote:
> 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
>
>

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
Microsoft MVP - ASP/ASP.NET


Relevant Pages

  • RegularExpressionValidator?
    ... I have this snippet: ... 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 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Backreferences in case statements
    ... checks for a regular expression. ... In the above snippet how can I use the instance variables pre_match ... IMHO it is generally a bad idea to use grouping in the way you do it because it will capture a lot that you are not interested in. ... Kind regards ...
    (comp.lang.ruby)
  • Re: Regexp to match an URL in an HTML <a href=""></a> tag
    ... > I am trying to craft a regular expression to filter an URL from a <a ... > I use the regular expression from this snippet of code: ...
    (comp.lang.perl)
  • Regexp to match an URL in an HTML <a href=""></a> tag
    ... I am trying to craft a regular expression to filter an URL from a <a ... I use the regular expression from this snippet of code: ... foreach my $message ... Charles ...
    (comp.lang.perl)
  • Re: Regexp to match an URL in an HTML <a href=""></a> tag
    ... > I am trying to craft a regular expression to filter an URL from a ... > the regular expression from this snippet of code: ...
    (comp.lang.perl)