Revalidate field using BootstrapValidator

浪子不回头ぞ 提交于 2019-12-30 11:38:23

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/40591361/revalidate-field-using-bootstrapvalidator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!