internetjason
internetjason

Reputation: 81

On Change validate field - datetimepicker

I have a field that utilizes a date picker as well as a validator. In the example below, I have pre-filled the date input. Now, erase the data and you will see it is no longer valid. Then click on the calendar icon to select a date. It does not re-validate until you move away from the input (blur), but I would rather it validate any time new text is entered from the date selector. Any suggestions?

JSFiddle

$(document).ready(function () {
    $('#app').bootstrapValidator();
});

$("#dob").on('blur', function () {
    $('#app').bootstrapValidator('revalidateField', 'dob');
});

$(function () {
    $('#dobpicker').datetimepicker({
        pickTime: false,
    });
});

Upvotes: 0

Views: 599

Answers (1)

Fahad Khan
Fahad Khan

Reputation: 1635

You can do it like this:

 $("#dobpicker").on("dp.change",function (e) {
      $('#app').bootstrapValidator('revalidateField', 'dob');      
 });

Working Fiddle

Upvotes: 1

Related Questions