Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error creating Regular Expression Validator control 1

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
571
US
Happy Friday, colleagues!
Not so happy for yours truly... [sad]
Subject line says what the problem I have. Here's the code (exactly as in the book "Murach's ASP.NET 4.6 Web Programming with C# 2015", pg. 271, fig. 7-13):

Code:
<asp:RegularExpressionValidator ID="revEmail1" runat="server" ErrorMessage="Email address" CssClass="text-danger" Display="Dynamic" 
     ValidationExpression="[COLOR=#CC0000][b]\w([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.])\w+)*[/b][/color]" 
    ControlToValidate="txtEmail1">Must be a valid Email address>
</asp:RegularExpressionValidator>

Let alone it's hard not to screw up typing this expression (in bold, red), but VS tells me... well, picture (Design screen) worth 1K words:

2022_05_06_15_27_Shopping_Cart_VS2019_RegExValidator_ErrorCreating_nc5sdg.jpg


I check all chars in this regex 3 times - exact match to the one in the book, so...
Where do I err?
Please advise!
AHWBGA!

Regards,

Ilya
 
but this ending parenthesis does not seem to have beginning parethesis:
\w([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.])\w+[highlight #FCE94F])[/highlight]*
 
Right!
It turns out that it's a typo in the book. I added this opening parenthesis in front - and it worked.
Thank you!

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top