Use jquery to detect changes in django-bootstrap-datepicker-plus

30 Views Asked by At

I am using django_bootstrap5 and django-bootstrap-datepicker-plus in my project. I have two datetime fields, I want to populate second field when first field is populated and I'm trying to detect this change using jquery, I tried following this question which is almost identical as mine, but it still does not work for me text

here is my form

widgets = {'date': DateTimePickerInput(attrs={'id': 'start-date'}),
                   "end_date": DateTimePickerInput(attrs={'id': 'end-date'},range_from="date")}

template form

<div class="col-md-3">
        <form method="post">
            {% csrf_token %}
            {% bootstrap_form form %}
            <button type="submit" class="btn btn-primary">Save</button>
        </form>
        </div>

jquery

$(document).ready(function () {
        $('#start-date').on('dp.change', function (ev) {
            // function logic
        });
    });
0

There are 0 best solutions below