资料验证的asp.net程序
<!-------资料验证:天乐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><s cript 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
}
}
</s cript></P><P>