<script type="text/javascript">
function isValidMail() {
var TextVal = document.getElementById("TextBox1").value;
var Regex = /^(?:\w+\.?)*\w+@(?:\w+\.)*\w+$/;
if (Regex.test(TextVal)){
alert(true);
}
else {
if (TextVal == "") {
alert("请输入电子邮件地址!!");
return false;
}
else {
alert("您好,你输入不正确,请重新输入;");
document.getElementById("TextBox1").value = "";
return false;
}
}
}
</script>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button3" runat="server" Text="Button" OnClientClick="return isValidMail()" OnClick="Button3_Click" />