<%@ Page clienttarget=downlevel %>
<html>
<head>
<title>Simple RegularExpressionValidator Sample</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server">
void ValidateBtnClick ( object src, EventArgs e ) {
if ( Page.IsValid ) {
lblmsg.Text = "Page is valid!";
}
else {
lblmsg.Text = "Zip code must be 5 numeric digits";
}
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>Simple RegularExpressionValidator Sample</h2></div>
<!-- #include virtual="~/shared/viewsrc_top.inc" -->
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<table bgcolor="#eeeeee" cellpadding=10>
<tr>
<th colspan=2><b>Enter a 5 digit zip code</b></th></tr>
<tr valign="top">
<td align=right>Zip Code:</td>
<td><asp:textbox id="TextBox1" runat="server" /></td></tr>
<tr align="center">
<td colspan=2>
<asp:requiredfieldvalidator runat="server"
controltovalidate="TextBox1"
display="dynamic"
errormessage="Field cannot be blank" />
</td></tr>
<tr>
<td colspan=2 align="center"><asp:button text="Validate" onClick="ValidateBtnClick" runat="server" /></td></tr>
</table>
<p><asp:label id="lblmsg" runat="server" />
<asp:regularexpressionvalidator runat="server"
controltovalidate="TextBox1"
validationexpression="^\d{5}$" />
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>