1
Watch the HTML code;
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Período:</label>
<div class="row">
<div class="col-sm-2">
<input autocomplete="off" id="idPeriodoInicio" class="form-control monthPicker listar_uj" name="periodoInicio" id="periodoInicio" placeholder="Período Inicial">
</div>
<div class="col-sm-2">
<input autocomplete="off" id="idPeriodoFim" class="form-control monthPicker listar_uj" name="periodoFim" id="periodoFim" placeholder="Período Final">
</div>
</div>
</div>
Is it possible to use this line code only to format the field? I don’t want to appear any calendar, I just want to simply at the time the user enters the field it validate the field with formatting.
function carregaCalendario(){
$(".monthPicker").datepicker({
dateFormat: 'MM/yy',
changeMonth: true,
changeYear: true,
showButtonPanel: false,
monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
// monthNames: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).val($.datepicker.formatDate('mm/yy', new Date(year, month, 1)));
}
});
$(".monthPicker").focus(function () {
$(".ui-datepicker-calendar").hide();
$("#ui-datepicker-div").position({
my: "center top",
at: "center bottom",
of: $(this)
});
});
}