<!-------资料验证:天乐comezxn@sina.com------------>
<!-------比较简单,以前写的,若有纰漏,请跟我联系---------->
<HTML>
<Body bgcolor="White">
<H3>Validator(资料验证)控制元件<Hr></H3></P><P><Form runat="server">
<Blockquote></P><P>Email:<ASP:TextBox id="Email" runat="server"/></P><P><ASP:RegularExpressionValidator id="Valid1" runat="server"
ControlToValidate="Email"
ValidationExpression=".{1,}@.{3,}" >
(Email 应含有@号)
</ASP:RegularExpressionValidator><p></P><P>您的电话:<ASP:TextBox id="Tel" runat="server"/></P><P><ASP:RegularExpressionValidator id="Valid2" runat="server"
ControlToValidate="Tel"
ValidationExpression="\([0-9]{2,3}\)[0-9]{2,4}-[0-9]{4}" >
(区号)您的电话
</ASP:RegularExpressionValidator><p></P><P>
您的地址:<ASP:TextBox Size=60 id="Addr" runat="server"/>
<!--------仿照了王国荣的《ASP.net领先研究》的程序------------>
<ASP:RegularExpressionValidator id="Valid3" runat="server"
ControlToValidate="Addr"
ValidationExpression="(.{1,}(市|镇|乡).{1,}(路|街|道).{1,}号.{0,})|(.{1,}邮政.{1,}信箱)" >
(必须含有 '市镇乡'、'路街道'、'号' 或 '邮政'、信箱')
</ASP:RegularExpressionValidator><p></P><P><ASP:Button id="Button1" Text=" 输入 " runat="server"
OnClick="Button1_Click" />
<ASP:Label id="Label1" runat="server"/></P><P></Blockquote></form>
<Hr></body>
</HTML></P><P><script Language="c#" runat="server">
public void Button1_Click (object sender, System.EventArgs e)
{
If(Page.IsValid) {
Label1.Text = "<p><Font Color=Red>资料验证 OK!</Font>"
Button1.Visible = False
}
}
</script></P><P>