ReactiveRaven / jqBootstrapValidation

A JQuery validation framework for bootstrap forms.
http://reactiveraven.github.io/jqBootstrapValidation
MIT License
1.35k stars 334 forks source link

Dynamic Rules - Doesn't really destroy #184

Open fobus42 opened 9 years ago

fobus42 commented 9 years ago

Hello,

I'm trying to use this plugin in dynamic forms. I have two fields. First fields value effects on the seconds validation rules. Both fields are text boxes and accepts integers

For Example

if FirstField < 0 then SecondField Required if FirstField > 0 then SecondField Required

I have write the conditions on FirstFields change event. I'm checking the FirstFields value and add or remove "reqired" property to the seconds ex: $('#SecondField').prop('required',null);

Then I'm destroying Validator

$("input,select,textarea").jqBootstrapValidation('destroy')

//recreating validator. $("input,select,textarea").jqBootstrapValidation()

Problem starts here; When I check if there is an error. $("input,select,textarea").jqBootstrapValidation('hasErrors')

it allways returns true, because recent configuration was having "required" but it is currently it doesn't have a required propery.

What is expected; Every time after destroy and recreate validation, it needs to load the last configuration and give the correct result on "hasErrors" call

How to reset to the last configuration?

gabrielibis commented 3 years ago

I have the same problem. Did you found the solution?