javascriptjqueryhtmlbootstrapvalidator

Bootstrapvalidator update status to invalid remains valid on active field


I have a manual validation on a couple fields that checks on the total value of the fields and if it stays below a certain threshold.

The problem is that on an invalid value set all the fields to invalid. All the fields get updated except the one that triggerd my code with an "oninput" event.

$('#order-entry').bootstrapValidator('updateStatus', $('#' + ids[i]), 'INVALID', 'lessThan');

The updating code is part of the triggered event and i am suspecting that the bootstrapvalidator is revalidating the field after my event has happend. How can i solve this?


Solution

  • I ended up using setTimeout to delay the updates until the function was done. So with a 200 ms delay.

    So basically this:

    (function(tIds) {
        setTimeout(
            function() {
                $('#order-entry').bootstrapValidator('updateStatus', $('#' + tIds[i]), 'INVALID', 'lessThan');
            }, 200);
    })(ids);