SKYGQ Form validation Ajax no refresh form submission

Source: Internet
Author: User
Tags json

1. The special requirements for Input checkbox selection can now be limited by the number of choices it chooses, or by selecting several to several.
2. Treat the input text text field, you can set the input value must be within a range. For example, the age limit for input is 18 to 78 years old.
3. Added a new interface, you can add validation rules
The interface instance is as follows:

The code is as follows Copy Code

var rules = {
"Coupon_amount": [/^0. ( [1-9]) {1,2}$/, "must be 0.85 such numbers"]
}
$.skygqcheckajaxform.addrules (rules);

The rule is the form of a key-value pair, and "Coupon_amount" represents the validation type, which means that the first parameter of the following array parameter is the validation rule, and the second parameter is the information that is prompted when the contents of the form do not conform to the validation rule.
This corresponds to the form initialization information:

The code is as follows Copy Code

{Name: "Zhekou", type: "Coupon_amount", Simple: "Discount", focusmsg: "Please fill in the discount factor"}


4. The name of the form field can support "[", "]", "." These three kinds of special symbols

In the demo, the form is initialized with the following JS:

The code is as follows Copy Code

$ (function () {
var rules = {
"Coupon_amount": [/^0. ( [1-9]) {1,2}$/, "must be 0.85 such numbers"]
}
$.skygqcheckajaxform.addrules (rules);
Second form validation
var items_array2 = [
{name: ' info[login] ', type: "username", simple: "User name", message: "What the aircraft, well fill in the username", focusmsg: ' The combination of numbers and English and underline and., beginning with letters, 4-20 characters ', Ajax:{method: ' Post ', url:base_url+ ' skygq_check_ajax_form_1_5/ajax.html ', Success_ Msg: ' Congratulations! User name available ', Failure_msg: ' Username already exists '},
{name: ' Info[password] ', type: ' Password ', simple: ' Password ', focusmsg: ' min Length: 6 max Length: 16 '},
{name: ' Info[confirm_password] ', type: ' eq ', to: ' Info[password] ', simple: ' Confirm password ', focusmsg: ' Please re-enter the password you filled in '},
{name: "Info[email]", type: "Mail", simple: "Email", focusmsg: ' Please fill in the real and most used mailbox '},
{name: "Info[age]", Simple: "Age", between:[18,78],focusmsg: ' Age must be greater than or equal to 18 less than or equal to 78 '},
{name: "Info[do_years]", simple: "Working age", type: "GT", Value:3,focusmsg: ' must be greater than 3 '},
{name: "sport[]", Simple: "Motion", Checked_limit:[2,2],focusmsg: "Please select 2 Sports"},
{name: "favourite[]", Simple: "Hobby", checked_limit:[4,7],focusmsg: "Please choose 4 to 7 Hobbies"},
{Name: "Sky.zhekou", type: "Coupon_amount", Simple: "Discount", focusmsg: "Please fill in the discount factor"}
];

$ ("#form2"). Skygqcheckajaxform ({
Items:items_array2,
Isajaxsubmit:true,
Success:showresponse2,
DataType: ' JSON '
});
function ShowResponse2 (responsetext, StatusText, XHR, $form) {
Alert ("Registered successfully")
Alert ("JSON return data is:" + responsetext);
}
});

Let's download a demo again. (PS: Download demo demo, and Dream Ploughing Online demo demo is not the same, no Ajax submission and no Ajax validation, just a simple front-end validation

Http://file.111cn.net/upload/2013/09/ajax.rar

Related Article

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.