The most convenient way to use the jquery Validate plugin Reomte method is to infer whether a user account has been registered through an AJAX request during user registration.
Jquery Validate plugin, call remote method validation parameters, remote use method:
increase in the Validate methodRemote: "Calibration Method", such as:Remote: "/test/checkaccount.jsp", then the checkaccount.jsp is account=$ ("#account"). Val (), this is Jquery.validate own initiative to participate, do not have to manually change. If the name of the reference is not a variable name, it can be changed by itself:
Remote: "/test/checkaccount.jsp?"
Paramname= "+ $ (" #account "). Val () at this point the check method needs to return a Boolean value, for example: The account can be Out.print (false) or account is not available out.print (true);
Here is the code for the registration of the Good Reach network:
$ ("#register"). Validate ({
Rules: {
"User.email": {
Required:true,
Email:true,
remote:{
Type: "POST",
URL: "/passport/account/validateemail",
data:{
Email:function () {return $ ("#email"). Val ();
}
}
}
Part of the code for the Sdg.registre.js network is omitted here
},
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
});
the corresponding HTML code <input type= "text" class= "Input-block-level Tips" name= "user.email" id= "email" > Many other HTML code for this page Everyone can go to the network to find the good.
the backstage of the net is to use the jfinal frame to write, because has not seen the good Tatsu net backstage code. How to realize the detail later is 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 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); /According to the EAMIL number from the database to find whether the email has been registered
if (isexisted )
Response.Write ("true");
Else
response.write (" false ");
return null;
}
}
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
JQuery Validate Insert Reomte use detailed instructions