Ajax Validate
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="AnsonWebShop.Web.login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="App_Themes/AnsonWebShop/test.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="User:"></asp:Label>
<input id="un" type="text" style="width: 150px" runat="server" onblur="checkEmailAddress(this.value, true);" /><div id="divE"></div><br />
<asp:Label ID="Label2" runat="server" Text="Pass:"></asp:Label>
<input id="pw" style="width: 150px" type="password" runat="server" /><br />
<input id="Button1" style="width: 184px" runat="server" onclick="loginin()" value="OK" />
<br />
<head runat="server">
<title>Untitled Page</title>
<link href="App_Themes/AnsonWebShop/test.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="User:"></asp:Label>
<input id="un" type="text" style="width: 150px" runat="server" onblur="checkEmailAddress(this.value, true);" /><div id="divE"></div><br />
<asp:Label ID="Label2" runat="server" Text="Pass:"></asp:Label>
<input id="pw" style="width: 150px" type="password" runat="server" /><br />
<input id="Button1" style="width: 184px" runat="server" onclick="loginin()" value="OK" />
<br />
<input type="button" name="btNext" id="btNext" onclick="return
checkEmailBorad();" value="Next" class="joinbtn" />
<br />
<br />
<script language="javascript" type="text/javascript">
function checkEmailAddress(strValue, isCheck)
{
var str = strValue.trim();
var uu = document.getElementById("un");
var d = document.getElementById("divEmail");
if(str.length < 1)
{
d.innerHTML = "<div class=\"check\">电子邮件地址不能为空</div>";
return false;
}
else
{
var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if(checkReg(reg, str))
{
if(isCheck)
{
var url = "CEE.aspx";
var pars = "EMail=" + StrCode(strValue);
var acheck = new Ajaxcheck.check({success: "divE"}, url, {method: "post", parameters: pars, onLoading: function(){$("divE").innerHTML = "<div class=\"loading\">检测中,请稍后……</div>";}});
}
return true;
}
else
{
d.innerHTML = "<div class=\"checkerror\">电子邮件地址不合法</div>";
return false;
}
}
}
function checkEmailAddress(strValue, isCheck)
{
var str = strValue.trim();
var uu = document.getElementById("un");
var d = document.getElementById("divEmail");
if(str.length < 1)
{
d.innerHTML = "<div class=\"check\">电子邮件地址不能为空</div>";
return false;
}
else
{
var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if(checkReg(reg, str))
{
if(isCheck)
{
var url = "CEE.aspx";
var pars = "EMail=" + StrCode(strValue);
var acheck = new Ajaxcheck.check({success: "divE"}, url, {method: "post", parameters: pars, onLoading: function(){$("divE").innerHTML = "<div class=\"loading\">检测中,请稍后……</div>";}});
}
return true;
}
else
{
d.innerHTML = "<div class=\"checkerror\">电子邮件地址不合法</div>";
return false;
}
}
}
function checkEmailBorad()
{
if(checkEmailAddress("un", false))
{
}
else
{
return false;
}
}
</script>
</form>{
if(checkEmailAddress("un", false))
{
}
else
{
return false;
}
}
</script>
</body>
</html>