revalidateField() method

Revalidate a particular field
revalidateField(field: String): Promise
(* denotes a required parameter)
ParameterTypeDescription
field*StringThe field name
This method is useful when the field value is effected by third parties (for example, attach another UI library to the field). Since there isn't an automatic way for FormValidation to know when the field value is modified in those cases, we need to revalidate the field manually.
Using the global script in the browser
const fv = FormValidation.formValidation(
document.getElementById('demoForm'),
{
...
}
);
fv
.revalidateField(...)
.then(function(status) {
// status can be one of the following value
// 'NotValidated': The field is not yet validated
// 'Valid': The field is valid
// 'Invalid': The field is invalid
...
});
Using the ES6 module
import { formValidation } from '/path/to/@form-validation/cjs/bundle/popular';
const fv = formValidation(
document.getElementById('demoForm'),
{
...
}
);
fv
.revalidateField(...)
.then(function(status) {
// status can be one of the following value
// 'NotValidated': The field is not yet validated
// 'Valid': The field is valid
// 'Invalid': The field is invalid
...
});
Using the npm package
import { formValidation } from '@form-validation/bundle/popular';
const fv = formValidation(
document.getElementById('demoForm'),
{
...
}
);
fv
.revalidateField(...)
.then(function(status) {
// status can be one of the following value
// 'NotValidated': The field is not yet validated
// 'Valid': The field is valid
// 'Invalid': The field is invalid
...
});
Look at the Integration page to see more examples.

See also