<head runat="server">
<title>无标题页</title>
<script language="javascript">
function check()
{
var email = document.getElementById('TextBox1');
var pwd = document.getElementById('TextBox2');
if (email.value=="" || pwd.value=="")
{
alert("请填写完整内容");
return false;
}
else
{
var mailStr = /(("w)+)@(("w)+).[cc|com|net|org|tv|cn]/ig;
if (!mailStr.exec(email.value))
{
alert('Email地址书写不正确!"n请您重新输入!');
email.value = '';
email.focus();
return false;
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return check();" OnClick="Button1_Click1" /></div>
</form>
</body>
先执行客户端的javascript函数,页面回送以后再执行服务器端的方法