I would like to know if there is any way to change the format of the datepicker dynamically using radio buttons, but the way I'm trying is not working ...
HTML
<input id="periodo" name="periodo" type="text" placeholder="Período">
<input id="radioDDMM" type="radio" name="typePeriodo" checked data-type="dd/mm" />
<label for="radioDDMM">Dia/Mês</label>
<input id="radioMMYYYY" type="radio" name="typePeriodo" data-type="mm/yyyy" />
<label for="radioMMYYYY">Mês/Ano</label>
JQuery
$(document).ready(function () {
$('#periodo').datepicker({
format: "dd/mm",
startView: "days",
minViewMode: "days",
language: 'pt-BR',
endDate: '0m',
orientation: 'bottom',
autoclose: true
});
$("[name='typePeriodo']").on('change', function () {
var type = $(this).attr('data-type');
if (type == "dd/mm") {
$('#periodo').datepicker({
altFormat: "dd/mm",
startView: "days",
minViewMode: "days",
})
} else if (type == "mm/yyyy") {
$('#periodo').datepicker({
altFormat: "mm/yyyy",
startView: "months",
minViewMode: "months",
})
}
});
});