Jquery Ajax implements user registration detection (asp.net)

Source: Internet
Author: User

aspx file

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
}

Asynchronous refresh implementation of a variety of ways, but also the use of a variety of JS framework, the above is implemented using the jquery framework Ajax to verify the existence of the user name. The first time such technical documents, inevitably have a shortage of

Ajax jquery page
$ ("#accounts"). Formvalidator ({onshow: "Enter user name", onfocus: "User name at least 4 characters, up to 10 characters", Oncorrect: "This user name can be registered"}. Inputvalidator ({min:4,max:10,onerror: "User name is at least 4 characters, up to 10 characters}"). Regexvalidator ({regexp: " Username ", datatype:" Enum ", OnError:" Incorrect user name format "})
. 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 ("Server does not return data, possible server busy, retry");
OnError: "This username is not available , please replace user name ",
onwait:" The user name is being verified for legality, please wait ... "
})

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.