jquery Plugin-Form form plug-in jquery.form.js

Source: Internet
Author: User

Tag:io   ar   for    Data    on   c    cti   amp   ad   

Beforesubmit:validate
function Validate (FormData, Jqform, Options) {//To validate the form here, and false to prevent the form from submitting until the rule is met if the rule is not met
Method one: Using Formdata parameters
for (var i=0; i < formdata.length; i++) {
if (!formdata[i].value) {
Alert (' Username, address and self-introduction cannot be empty! ');
return false;
}
}

Way two: Using Jqform object
var form = jqform[0]; Convert a form to a DOM object
if (!form.name.value | |!form.address.value) {
Alert (' username and address cannot be empty, self-introduction can be empty! ‘);
return false;
}

Method Three: Using the Fieldvalue () method, Fieldvalue is a form plug-in method that can find the values of the elements in the form, returning a collection.
var usernamevalue = $ (' input[name=name] '). Fieldvalue ();
var addressvalue = $ (' input[name=address] '). Fieldvalue ();
if (!usernamevalue[0] | |!addressvalue[0]) {
Alert (' username and address cannot be empty, self-introduction can be empty! ‘);
return false;
}

var queryString = $.param (FormData); Assembly data
alert (queryString); Similar: name=1&add=2
return true;
}

(GO) jquery plugin-form form plug-in jquery.form.js

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.