Use Jquery Ajax in Asp.net to detect User Registration (verify whether the user name is saved)

Source: Internet
Author: User

The jquery plug-in is used to verify the user name. Here, jquery ajax is used to verify whether the user name exists. Please refer to the following link for source code download.

Ajax implemented by the jquery framework verifies whether the user name exists. JS
Copy codeThe Code is as follows:
$ ("# Accounts "). formValidator ({onshow: "Enter the user name", onfocus: "The user name must be at least 4 characters and a maximum of 10 characters", oncorrect: "This user name can be registered "}). inputValidator ({min: 4, max: 10, onerror: "The user name must contain at least 4 characters and a maximum of 10 characters "}). regexValidator ({regexp: "username", datatype: "enum", onerror: "Incorrect username 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 ("the server does not return data. The server may be busy. Please try again ");},
Onerror: "This user name is unavailable. Please change the user name ",
Onwait: "the validity of the user name is being verified. Please wait ..."
})

Source code of NameExist. aspx implementation
Copy codeThe Code is as follows:
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 can be implemented in multiple ways. You can also use multiple js frameworks. The preceding example uses ajax implemented by the jquery framework to verify whether the user name exists. The first time such a technical document is published, it is inevitable that there are deficiencies, please see the cold...

Download is provided below

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.