JQuery调webservice实现邮箱验证(是否已被占用)
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/WebService1.asmx" />
</Services>
</asp:ScriptManager>
SinaWeiBo.WebService1.cunzai($(this).val(), a, b)
{
function a(result) {
if (result == "该邮箱已存在请重新输入") {
$('#txtusername').val('');
$('#txtusername').focus();
$('#emailyz').text(result);
}
else { $('#emailyz').text('可以使用'); }
}
function b() {
$('#emailyz').text('没有返回值');
}
}
webservice:
public string cunzai(string txtusername)
{
//判断邮箱存不存在
try
{
SinaWeiBo.BLL.T_Users bt1 = new BLL.T_Users();
DataSet ds = new DataSet();
ds = bt1.GetList(" T_UserEmail='" + txtusername + "'");
string cha = ds.Tables[0].Rows[0][0].ToString();
return "该邮箱已存在请重新输入";
}
catch {
return "正确";
}
}
补充:web前端 , JavaScript ,