Based on the field status, the field and its container are marked as success or error element.
For
Bootstrap form, the plugin will add
.has-success
or
.has-danger
class to the container element. It also adds
.is-valid
or
.is-invalid
class to the field element. If you think that it's better to indicate error status only due to the similarity of these status colors, you can remove
.has-success
class from the container.
FormValidation
.formValidation(
form,
{
fields: {
...
},
plugins: {
...
},
}
)
.on('core.element.validated', function(e) {
if (e.valid) {
const groupEle = FormValidation.utils.closest(e.element, '.form-group');
if (groupEle) {
FormValidation.utils.classSet(groupEle, {
'has-success': false,
});
}
FormValidation.utils.classSet(e.element, {
'is-valid': false,
});
}
});