jquery Validate is a common form validation plugin. Encounter a jquery validate form validation does not trigger an issue
Current wording:
$ (function () {
$ ("#form"). Validate ({
rules: {
ThemeColor: {
required:true
},
...
},
messages: {
ThemeColor: {
required: ' Required ',
},
...
}
});
});
<div class= "Btnwrap" >
<button type= "button" class= "btn btn-block btn-radius btn-st btn-caution submit-btn" id= "btn" > Upload
</button>
</div>
Click on the Upload button to contact the post verification, the test verification can not be triggered. Careful study of the use of the method found that the above wording can only be triggered using the submit.
<div class= "Btnwrap" >
<button type= "Submit" class= "btn btn-block btn-radius btn-st btn-caution submit-btn" id= "btn" > Upload
</button>
</div>
if you want to implement the single-touch verification on the normal button, you need to modify it slightly:
//write form validation function ValidForm, invoke validation function object within Validation button Registration button click event
function ValidForm () {
/ * Key here adds a return, which returns a validate object that has a form method that returns whether or not to pass the validation * /
return $ ("#form"). Validate ({
rules: {
ThemeColor: {
required:true
},
...
},
messages: {
ThemeColor: {
required: ' Required ',
},
...
}
});
}
//form validation
$ (ValidForm ());
The above section has implemented the function of anonymous functions, the following describes how to implement form validation through the normal button
$ ("#btn"). Click (function () {
if (ValidForm (). form ()) {
//through form validation, write your own code below
} else {
//checksum does not pass, nothing is done, the calibration information is displayed on the form normally
}
});
jquery Validate single-touch release verification