mastersuse
mastersuse

Reputation: 988

How to auto clear/reset datepicker using on.change function?

I have tried many ways below to clear/reset value for datepicker using on.(change) function, but it does not happen. I am using Air Datepicker plugin with Bootstrap 4.

HTML

<select title="-- NODE --" id="nodes" class="selectpicker form-control" multiple>
    <option value="">-- NODE --</option>
</select>
<input id="date" type="text" class="form-control datepicker-here">

JS (3 ways)

$("#nodes").change(function() {
    $("#date").empty();
});

$("#nodes").change(function() {
    $("#date").val("").datepicker(clear);
});

$("#nodes").change(function() {
    $("#date").data(datepicker).clear()
});

Upvotes: 0

Views: 1044

Answers (1)

germmand
germmand

Reputation: 1220

How about this?

$('#nodes').on('change', function() {
    $('#date').val('');
});

Upvotes: 1

Related Questions