validate() method

Validate all fields
It might be used when you want to validate the form manually when pressing given button.
validate(): Promise
If you want the form to be validated automatically when pressing its Submit button, use the SubmitButton plugin
Using the global script in the browser
const fv = FormValidation.formValidation(
document.getElementById('demoForm'),
{
...
}
);
// Validate the form when click on a link or normal button
fv
.validate()
.then(function(status) {
// status can be one of the following value
// 'NotValidated': The form is not yet validated
// 'Valid': The form is valid
// 'Invalid': The form is invalid
...
});
Using the ES6 module
import { formValidation } from '/path/to/@form-validation/cjs/bundle/popular';
const fv = formValidation(
document.getElementById('demoForm'),
{
...
}
);
// Validate the form when click on a link or normal button
fv
.validate()
.then(function(status) {
// status can be one of the following value
// 'NotValidated': The form is not yet validated
// 'Valid': The form is valid
// 'Invalid': The form is invalid
...
});
Using the npm package
import { formValidation } from '@form-validation/bundle/popular';
const fv = formValidation(
document.getElementById('demoForm'),
{
...
}
);
// Validate the form when click on a link or normal button
fv
.validate()
.then(function(status) {
// status can be one of the following value
// 'NotValidated': The form is not yet validated
// 'Valid': The form is valid
// 'Invalid': The form is invalid
...
});

See also