The jQuery formValidator Form Verification plug-in is open-source, including API help, source code, and examples.

Source: Internet
Author: User

Bug Description: The ajaxValidator function has an error after submission. If it stays on this page, triggering verification again will keep the prompt content in the onload status.

This bug has been fixed. Please download it again.

2008/7/17 14:12:00 jQuery formValidator 3.1ver

1. Add the empty attribute for inputValidator. Used to set whether the control text value can be empty on both sides. For details, see the password verification code in demo1.
This attribute is an object. The default value is {leftempty: true, rightempty: true, emptyerror: null}
Leftempty: whether to allow null on the left
Rightempty: whether to allow null on the right
Emptyerror: the prompt when this error occurs. If it is null, The onerror attribute is used to prompt the error.
Note: it can only be used when type: "size" is used, that is, when the length is compared.

2. Modify the syntax of the Automatic Build prompt layer. Add the relativeid attribute to the formValidator function.
Relativeid: indicates the relative positioning control ID of the prompt layer. If it is null, the ID of the current check control is used.
Tipid: indicates the ID of the automatically created prompt layer. If it is null, use the ID + "Tip" of the current validation control to name it.

3. Fixed the bug of the beforesend attribute in the ajaxValidator function. The Code forgets to pass its unique parameter.

4. Fixed the bug where the ajaxValidator function could not obtain Chinese characters in the background.

5. Updated the upgrade record, user manual, and added two questions.
1. On-site demonstration
Http://img.jb51.net/online/formValidator3.1/demo.html

2. Main Functions of the jQuery pageValidator plug-in

Supports verification of all types of client controls
Supports all the selector Syntax of jQuery, as long as the control has a unique ID and type attribute
Supports expansion of functions and regular expressions. The extension library formValidatorReg. js is provided. You can add and modify the content freely.
Two verification modes are supported. First: Text prompt (showword mode); Second: pop-up window prompt (showalert Mode)
Multiple Validation groups are supported. If a page has multiple submit buttons and you have to submit them separately, you must perform different verification before submitting them. Therefore, you must use the verification group function.
Supports information prompting in four states, allowing you to flexibly control whether or not four States are displayed. First: prompt when you open the webpage; Second: prompt when you get the focus; Third: prompt when the focus is lost, and fourth: error message indicating verification failure when the focus is lost.
Supports automatic creation of the prompt layer. Can be precisely located.
Supports custom error message.
Supports control of character length, value range, and number of selections. The value range supports the numeric and numeric types. The selected number supports three controls: radio, checkbox, and select.
Comparison of Two control values is supported. Currently, you can compare string and numeric types.
Server-side verification is supported.
Supports validation of input formats.

3. jQuery formValidator plug-in API help document
Click here for help documentation

4. Download API help, source code, and examples
Http://xiazai.jb51.net/jslib/formValidator2.4.rar
Http://xiazai.jb51.net/jslib/formValidator3.1.rar

Verification Code upgradeer

5. Sample Code

<Script type = "text/javascript">
$ (Document). ready (function (){
$. FormValidator. initConfig ({onError: function () {alert ("check failed. For details about the error, see the error prompt ")}});
$ ("# Test1 "). formValidator ({onshow: "Enter the user name", onfocus: "The user name must be at least 6 characters and a maximum of 10 characters", oncorrect: "Congratulations, you have entered the correct information "}). inputValidator ({min: 6, max: 10, onerror: "The user name you entered is invalid. Please confirm "});

$ ("# Test2 "). formValidator ({onshow: "Please select your hobbies (at least three, up to five)", onfocus: "You should select at least three, up to five ", oncorrect: "Congratulations, you selected it "}). inputValidator ({min: 3, max: 5, onerror: "The number you selected is incorrect (at least three, up to five )"});

$ ("# Test3 "). formValidator ({onshow: "select at least one of your hobbies.", onfocus: "select at least one.", oncorrect: "congratulations, you have selected "}). inputValidator ({min: 1, onerror: "The number you selected is incorrect "});

$ ("# Xueli "). formValidator ({onshow: "select your education level", onfocus: "education level required", oncorrect: "Thank you for your cooperation "}). selectValidator ({onerror: "Have you forgotten your degree! "});

$ ("# Password1 "). formValidator ({onshow: "enter the password", onfocus: "The two passwords must be consistent", oncorrect: "consistent passwords "}). inputValidator ({min: 1, onerror: "The password cannot be blank. Please confirm "}). compareValidator ({desID: "password2", operateor: "=", onerror: "Two different passwords, please confirm "});

$ ("# Nl "). formValidator ({onshow: "Enter the age between 1 and 99 years old)", onfocus: "Only numbers between 1 and 99 can be entered.", oncorrect: "congratulations, you entered the correct "}). inputValidator ({min: 1, max: 99, type: "value", onerror: "The age must be between 1 and 99. Please confirm "});

$ ("# Aiguo "). formValidator ({onshow: "patriotic people must select Oh", onfocus: "You have to think carefully", oncorrect: "I don't know if you love or not, you chose "}). inputValidator ({min: 1, max: 1, onerror: "Aren't you patriotic? Select for me !!!! "});

$ ("# Shouji "). formValidator ({empty: true, onshow: "Enter your mobile phone number. It can be blank.", onfocus: "If you have entered the phone number, you must enter it correctly.", oncorrect: "Thank you for your cooperation", onempty: "Do you really want to leave a mobile phone number? "}). InputValidator ({min: 11, max: 11, onerror: "the mobile phone number must be 11 digits. Please confirm "}). regexValidator ({regexp: "^ [1] [0-9] {10} $", onerror: "Your entered mobile phone format is incorrect "});

$ ("# Lxdh "). formValidator ({empty: true, onshow: "Enter your contact number. It can be blank.", onfocus: "If you have entered it, you must enter it correctly. The format is as follows: 0577-88069620 ", oncorrect:" Thank you for your cooperation ", onempty:" Do you really want to leave a contact number? "}). RegexValidator ({regexp:" ^ [[0-9] {3}-| \ [0-9] {4}-]? (\ [0-9] {8} | [0-9] {7 })? $ ", Onerror:" the contact number format you entered is incorrect "});

$ ("# Ms "). formValidator ({onshow: "Enter your description", onfocus: "The description must contain at least 10 or 20 characters." oncorrect: "congratulations, you entered the correct "}). inputValidator ({min: 20, onerror: "The length of the description you entered is incorrect. Please confirm "});
});
</Script>

6. Special Instructions

If you encounter any problems during use, please leave a message to me. If you find bugs, please do not modify them by yourself. Also, please leave a message to improve the plug-in and truly serve every program developer.
Please keep the copyright statement of the plug-in. Thank you.

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.