代碼如下:
<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 "正確";
}
}