Question:
I have this code in javascript:
$(function() {
$("#calendario").datepicker({
changeMonth: true,
todayHighlight: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
dateFormat: 'dd/mm/yy',
dayNames: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado', 'Domingo'],
dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S', 'D'],
dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'],
monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
;
monthNamesShort: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']
});
});
<div id="calendario"> </div>
And just the div
above to call the calendar.
How do I register a value in datepicker
? Remembering that it has to be manageable, that is, you can register more than 1.
Answer:
Come on, first thing, remove the semicolon causing syntax error [Line 12].
Now for your questions:
How do I register a value in datepicker?
When you talk about registration, it gets kind of broad, it can be two things in my opinion.
1 – Set a Default value:
$("#calendario").datepicker( "setDate", "10/12/2015" );
2 – Get a selected value:
onSelect: function() {
var dateAsObject = $(this).datepicker('getDate'); // pega valor selecionado
console.log(dateAsObject);
}
Example working on: Jsfiddle
But if you want several dates to be selected in the same field for example 25/12/2015,26/12/2015
etc… You will have to use a Plugin because this is not supported in jQueryUI datepicker ;(
A plugin you can use is: MultDatepicker