Recently, the project entered the end of the project, mainly to provide some training to the customer. Each time a customer registers for a system, all the information is displayed. After clicking OK, if the user name is in the background, it cannot be added, however, the information entered on the page may be gone, for example, the password items will be cleared. This is an unfriendly place. After you enter the user name in many forums on the internet, you will be able to determine whether the user can be filled out after you lose the focus. You will be able to add this function to the project ~~
Add JS in front-end devices
<! --
Var xmlHttp;
Function createXMLHttpRequest (){
If (window. ActiveXObject ){
XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ");
}
Else if (window. XMLHttpRequest ){
XmlHttp = new XMLHttpRequest ();
}
}
Function checkUserName (){
Var UserName = document. getElementById ('tbxmanagername ');
If (UserName. value = "")
Return;
CreateXMLHttpRequest ();
Var url = "check_user.aspx? UserName = "+ UserName. value;
XmlHttp. open ("GET", url, true );
XmlHttp. onreadystatechange = handleStateChange;
XmlHttp. send (null );
}
Function handleStateChange (){
If (xmlHttp. readyState = 4 ){
If (xmlHttp. status = 200 ){
Var isValid = xmlHttp. responseText;
Var checkResult = document. getElementById ("checkResult ");
CheckResult. innerHTML = (isValid = "true ")? " & nbsp; congratulations! ":" & nbsp; this user name already exists. Select the base user name! ";
}
}
}
Background check_user.aspx.csprivate void Page_Load (object sender, System. EventArgs e)
{
String UserName = Request. QueryString ["UserName"];
// Validate
Bool isValid = false;
Int count = 0;
Count = (new DPM. Sys. ManagerBR (). GetResultByCondition (ManagerDS. MANAGER_TABLE, "Manager_LoginName = '" + UserName + "'");
If (count = 0)
IsValid = true;
Response. Clear ();
Response. Write (isValid? "True": "false ");
Response. End ();
}
The running effect is as follows:
Registrable:
Cannot register: