<script runat="server">
sub submit(sender As Object, e As EventArgs)
if Page.IsValid then
lbl.Text="页面有效!"
else
lbl.Text="页面无效!"
end if
end sub
</script>
<html>
<body>
<form runat="server">
请输入 US 邮政编码:
<asp:TextBox id="txtbox1" runat="server" />
<br /><br />
<asp:Button text="提交" OnClick="submit" runat="server" />
<br /><br />
<asp:Label id="lbl" runat="server" />
<br />
<asp:RegularExpressionValidator
ControlToValidate="txtbox1"
ValidationExpression="\d{5}"
EnableClientScript="false"
ErrorMessage="邮编必须是五位数字!"
runat="server" />
</form>
</body>
</html>