Revalidate field using BootstrapValidator

ToyRobotic picture ToyRobotic · Nov 14, 2016 · Viewed 8.5k times · Source

I got a project from a new cutomer and the old programmer used BootstrapValidator 0.4.5 in this project.

The problem is that I build a autofil action for some fields, but the validation it not working for this fields after autofill or more excat after the autofill the validation is not call.

The validation only works for real user action.

Here is a part how I made the autofill.

// autofill
if (options.targetBank) 
{
    options.targetBank.val(data.bankData.name).change();
}

// maybe how to call the revalidation action
$( "#inputBank" ).change(function() {
    $(this).revalidation();
});

And I dont know how to call the validation, because there is no more documentation for 0.4.5.

Has anyone an idea ?

Answer

Zakaria Acharki picture Zakaria Acharki · Nov 14, 2016

You could use the API method revalidateField, It's used when you need to revalidate the field which its value is updated by other plugin :

$( "#inputBank" ).change(function() {
    $(this).closest('form').bootstrapValidator('revalidateField', $(this).prop('name'));
});

Hope this helps.