I'm looking for the way that when the checkbox flages change the format of the datepicker. This is my Jquery code
$(document).on('click','#chk_out',function ()
{
if ($('#chk_out').is(':checked'))
{
$( ".datepicker" ).datepicker({ minDate: "-15D", maxDate: "+0D" });
$( ".datepicker" ).datepicker( "option", "dateFormat","yy-mm-dd");
}
else
{
$( ".datepicker" ).datepicker({ minDate: "-1D", maxDate: "+0D" });
$( ".datepicker" ).datepicker( "option", "dateFormat","yy-mm-dd");
}
});
This is the HTML code
<div class="form-group">
<h5>Incidencia extemporánea</h5><input type="checkbox" name="chk_out" id="chk_out" class="">
</div>
<div class="form-group">
<h5>Fecha del incidente</h5>
<input type="text" id="fecha" class="datepicker" readonly>
</div>
Is not doing it, can you support me? Thank you. I did this fiddle link When the checkbox is checked you should enable me 15 days ago