Customize a validator--------------------------when the user registers, whether the username conforms to the rules and the time already exists in the database checksum

Source: Internet
Author: User

Instance:

<!--custom Check form-->$.validator.addmethod ("Checkusername",      //Check rule name, similar to Requiredfunction (Value,element, params) {//define a flag flag to mark whether the user name already exists var flag = False;$.ajax ({"Async": false,//must be synchronized here, because asynchronous processing, first executes the return statement, resulting in the inability to effectively return                "url": "${pagecontext.request.contextpath}/checkusername", "data": {"username": Value}, "type": " POST "," DataType ":" JSON "," Success ": function (data) {flag = Data.isexist;  Indicates whether the user name already exists in the database});//false indicates that the validator does not pass, that is, the user name is already in the database return!flag;});    Where: Value: Indicates the label entered for the check.        /element: Indicates the label in which the check is located   //        params: The parameter that represents the check rule

  

  

Customize a validator--------------------------when the user registers, whether the username conforms to the rules and the time already exists in the database checksum

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.