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