asaglimbeni / django-datetime-widget

Bootstrap django-datetime-widget is a simple and clean widget for DateField, Timefiled and DateTimeField in Django framework. It is based on Bootstrap datetime picker, supports both Bootstrap 3 and Bootstrap 2
Other
218 stars 125 forks source link

Duplicate ID in rendered widgets #103

Open dtougas opened 7 years ago

dtougas commented 7 years ago

Django form widgets automatically render an ID attribute on an INPUT tag. Your widget adds a duplicate ID attribute to the outer wrapping DIV. Since IDs should be unique, this violates the HTML spec, and can cause errors when attempting to use javascript/jquery to access the form fields via ID.

Here is an example of the output. Note that the IDs on both the DIV and the INPUT are the same.

<div id="id_date" class="input-group date">
       <input class="form-control" id="id_date" name="date" type="text">
       <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
       <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>