Jquery Ajax實現使用者註冊檢測(asp.net)

來源:互聯網
上載者:User

aspx檔案

 

protected void page_load(object sender, eventargs e)
{
string accounts = request["accounts"];
loginnameexist(accounts);
}
public void loginnameexist(string accounts)
{
iusers user = agileeis.web.dal.interface.dalhelper.dalmanager.createusers();
user.session = contexthelper.session;
user.accounts = accounts;
user.refresh();
if (!user.exists)
{
response.write("1");
}
else
{
response.write("0");
}
response.end();
return;
}

非同步重新整理實現方式有多種,也可以藉助js的多種架構,以上是使用jquery架構實現的ajax 驗證使用者名稱是否存在。首次發這樣的技術文檔,難免有不足之外

ajax jquery頁面
$("#accounts").formvalidator({onshow:"請輸入使用者名稱",onfocus:"使用者名稱至少4個字元,最多10個字元",oncorrect:"該使用者名稱可以註冊"}).inputvalidator({min:4,max:10,onerror:"使用者名稱至少4個字元,最多10個字元"}).regexvalidator({regexp:"username",datatype:"enum",onerror:"使用者名稱格式不正確"})
.ajaxvalidator({
type : "get",
url : "/ws/nameexist.aspx",
datatype : "json",
success : function(data){
if( data == "1" )
{
return true;
}
else
{
return false;
}
},
buttons: $("#submit"),
error: function(){alert("伺服器沒有返回資料,可能伺服器忙,請重試");},
onerror : "該使用者名稱不可用,請更換使用者名稱",
onwait : "正在對使用者名稱進行合法性校正,請稍候..."
})

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.