asp:RegularExpressionValidator for email address (C#)
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show RegularExpressionValidator</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label
id="lblEmail"
Text="Email Address:"
AssociatedControlID="txtEmail"
Runat="server" />
<asp:TextBox
id="txtEmail"
Runat="server" />
<asp:RegularExpressionValidator
id="regEmail"
ControlToValidate="txtEmail"
Text="(Invalid email)"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
Runat="server" />
<br /><br />
<asp:Button
id="btnSubmit"
Text="Submit"
Runat="server" />
</div>
</form>
</body>
</html>
Related examples in the same category