The most convenient way is to use the jquery Validate plugin Reomte method to determine whether or not the user account is registered by Ajax request when the user registers.
Jquery Validate plug-in, call remote method validation arguments, remote usage:
in the Validate method, addRemote: "Calibration Method", such as:Remote: "/test/checkaccount.jsp", then the parameter passed into the checkaccount.jsp is account=$ ("#account"). Val (), this is the Jquery.validate automatic parameter, without manual modification, if the parameter name is not a variable name, you can modify it by itself:
Remote: "/test/checkaccount.jsp?paramname=" + $ ("#account"). Val () the checksum method should return a Boolean value, for example: The account can be Out.print (false) or the account is not available out.print (true);
The registration code for the network is posted here:
$ ("#register"). Validate ({
Rules: {
"User.email": {
Required:true,
Email:true,
remote:{
Type: "POST",
URL: "/passport/account/validateemail",
data:{
Email:function () {return $ ("#email"). Val ();
}
}
}
//here omit the net Part of the code for Sdg.registre.js
},
messages : {
" User.email ": {
required:" Please enter your email! ",
email:" Bad mailbox format! ",
Remote: "The mailbox has been registered!"
}
//omitted here net sdg.registre.js part code
},
//here omit good reach net sdg.registre.js part code
});
corresponding HTML code <input type=" text "class=" Input-block-level Tips "name=" User.email "id=" email > more HTML code for this page You can get yourself to the good up net go find it. net background is written with the jfinal framework, because did not see the backend code of the network, how to achieve the specific after the unclear.
The general method of checking in the background is:
Here is an example of SPRINGMVC, which lists the core code
@Controller
@RequestMapping ("/passport/account")
public class Useraction {
@Autowired
Usermanager usermanager;//User Management class, responsible for reading user data from the data
@RequestMapping (value =" /validateemail ", method = Requestmethod.post)
public String Validateemail ( HttpServletRequest request,httpservletresponse response) {
String email= Request.getparamaters ("user.email ");
Boolean isexisted=usermanager.isexisteduser (email); /from the database according to the EAMIL, whether the email is registered
if (isexisted )
Response.Write ("true");
Else
response.write (" false ");
return null;
}
}