JQuery Validate Insert Reomte use detailed instructions

Source: Internet
Author: User

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

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.