on() method

Listen on particular event
on(event: String, func: Function): Core
(* denotes a required parameter)
ParameterTypeDescription
event*StringThe event name
func*FunctionThe event handler
Using the global script in the browser
const fv = FormValidation.formValidation(
document.getElementById('demoForm'),
{
...
}
);
const invalidFieldHandler = function(field) {
// `field` is name of invalid field
...
};
fv.on('core.field.invalid', invalidFieldHandler);
Using the ES6 module
import { formValidation } from '/path/to/@form-validation/cjs/bundle/popular';
const fv = formValidation(
document.getElementById('demoForm'),
{
...
}
);
const invalidFieldHandler = function(field) {
// `field` is name of invalid field
...
};
fv.on('core.field.invalid', invalidFieldHandler);
Using the npm package
import { formValidation } from '@form-validation/bundle/popular';
const fv = formValidation(
document.getElementById('demoForm'),
{
...
}
);
const invalidFieldHandler = function(field) {
// `field` is name of invalid field
...
};
fv.on('core.field.invalid', invalidFieldHandler);