Skygq Form Verification ajax refreshing form submission

Source: Internet
Author: User

This article will introduce you to the Skygq Form Verification example for no-refreshing ajax form submission. If you need to know more, please refer.

1. For special requirements of input checkbox selection, we can limit the number of options, so that we can select only a few or between several.
2. For the input text field, you can set that the input value must be within a range. For example, the input age is between 18 and 78 years old.
3. A new interface is added to add verification rules.
The interface instance is as follows:

The Code is as follows: Copy code

Var rules = {
"Coupon_amount": [/^ 0. ([1-9]) {0.85} $/, "must be a number like"]
}
$. SkygqCheckAjaxForm. addRules (rules );

The rule is in the form of a key-value pair. "coupon_amount" indicates the verification type, which corresponds to the type parameter. The first parameter of the following array parameter is the verification rule, the second parameter indicates the information that is prompted when the content of the form does not comply with this verification rule.
The corresponding form initialization information is as follows:

The Code is as follows: Copy code

{Name: "zhekou", type: "coupon_amount", simple: "discount", focusMsg: "Please fill in the discount coefficient "}


4. The form field names can be "[", "]", or ".".

The js used for form initialization in the DEMO is as follows:

The Code is as follows: Copy code

$ (Function (){
Var rules = {
"Coupon_amount": [/^ 0. ([1-9]) {0.85} $/, "must be a number like"]
}
$. SkygqCheckAjaxForm. addRules (rules );
// Verify the second form
Var items_array2 = [
{Name: "info [login]", type: "username", simple: "username", message: ", please fill in the username", focusMsg: 'digits and English letters and underlines and. A combination of 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: 'user name already exists '}},
{Name: "info [password]", type: 'Password', simple: "password", focusMsg: 'Minimum length: 6 maximum length: 16 '},
{Name: "info [confirm_password]", type: 'eq ', to: 'info [password]', simple: "Confirm password", focusMsg: 'Enter your password again '},
{Name: "info [email]", type: "mail", simple: "Email", focusMsg: 'Enter the real and most common mailboxes '},
{Name: "info [age]", simple: "age", between: [], focusMsg: 'Age must be 18 or less than 78 '},
{Name: "info [do_years]", simple: "Service Life", type: "gt", value: 3, focusMsg: 'must be greater than 3 '},
{Name: "sport []", simple: "sport", checked_limit: [2, 2], focusMsg: "select 2 sports "},
{Name: "favorite []", simple: "hobbies", checked_limit: [], focusMsg: "select 4 to 7 hobbies "},
{Name: "sky. zhekou", type: "coupon_amount", simple: "discount", focusMsg: "Please fill in the discount coefficient "}
];

$ ("# Form2"). skygqCheckAjaxForm ({
Items: items_array2,
IsAjaxSubmit: true,
Success: showResponse2,
DataType: 'json'
});
Function showResponse2 (responseText, statusText, xhr, $ form ){
Alert ("registered successfully ")
Alert ("JSON returned data:" + responseText );
}
});

Download another DEMO. (PS: The downloaded DEMO is different from the Online DEMO of mengsanqiu. There is no ajax verification without ajax submission, but a simple front-end verification.

Http://file.bKjia. c0m/upload/1/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.