the native checkValidity () method returns a Boolean value. True indicates that the check is passed, and false indicates that the check is not passed. Therefore, the submit form can be encapsulated as the following function.
function submitForm (action) {
var form = document.getElementById ("form");
form.action = action;
if (form.checkValidity ()) {
form.submit();
}
}
but this checkValidity () method only validates some of the basic checks provided by the browser api. Now you need to customize some checks (for example, verify that the form A value must be greater than the form B value. And whether a form value in the background of the ajax request is verified repeatedly. How to improve the method to make it a general method.