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