1
I’m using the bootstrap datepicker, but when I make some modifications they don’t apply
var defaults = $.fn.datepicker.defaults = {
autoclose: false,
beforeShowDay: $.noop,
calendarWeeks: false,
clearBtn: true,
daysOfWeekDisabled: [],
endDate: Infinity,
forceParse: true,
format: 'dd/mm/yyyy',
keyboardNavigation: true,
language: 'pt',*
minViewMode: 0,
multidate: false,
multidateSeparator: '-',
orientation: "auto",
rtl: false,
startDate: -Infinity,
startView: 0,
todayBtn: false,
todayHighlight: false,
weekStart: 0
};
*I put the language pt and changed tbm here:
var dates = $.fn.datepicker.dates = {
en: {
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
today: "Today",
clear: "Clear"
},
pt: {
days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab", "Dom"],
daysMin: ["Do", "Sg", "Te", "Qa", "Qi", "Sx", "Sa", "Do"],
months: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
monthsShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
today: "Hoje",
clear: "Limpar"
}
};
Using it as follows:
<form method="post" action="">
Início do período:
<input type="text" id="calendarioIni" name="dataInicio">
Fim do período:
<input type="text" id="calendarioFim" name="dataFim">
<input style="display: none;" type="submit" value="Consultar" />
<br><br><br>
<?php if(isset($_POST['dataInicio']) && isset($_POST['dataFim']))
{
$dataIni = $_POST['dataInicio'];
$dataFim = $_POST['dataFim'];
echo $dataIni."<br>";//Teste para verificar o valor nas variáveis que recebem a data via POST
echo $dataFim."<br>";
}
?>
</form>
When I open the calendar it is in English, as I do to apply this modification?
$(document).ready(function()
{
$('#calendarioIni').datepicker({
format: 'dd/mm/yyyy',
startDate: '01/01/1998', // 1 de Janeiro de 1998
endDate: '31/12/1998', // 31 de Janeiro de 1998,
language: "pt-BR",
onSelect: checaVazio
});
});
but still in English
– V.Avancini
You wouldn’t have to do that. Just include this official script in your code:
<script type="text/javascript" src="https://uxsolutions.github.io/bootstrap-datepicker/bootstrap-datepicker/js/locales/bootstrap-datepicker.pt-BR.min.js"></script>
and put the optionlanguage: "pt-BR"
in its element.– user98628
when I put language: "en-br" the calendar doesn’t open anymore
– V.Avancini
You are doing something wrong. Look at Mark’s answer below.
– user98628
really, I had forgotten a comma, but even so, it’s still in English and Marcus’s didn’t work either
– V.Avancini
Now that I’ve noticed, Chrome is in English, but Mozila and IE is in Portuguese...
– V.Avancini
No Chrome here gets in PT-BR normally. Look my answer below. It’s working.
– user98628
A comma was missing after
language: "pt-BR"
... Always place a comma at the end of each line inside the object, to separate the values, except in the last line. Without this single comma, it gives error in the whole script.– Sam
Yes Dvd, I fixed it already, I just forgot to edit here, I even commented here, if you notice some comments above you will see. Paulo, I had already seen its implementation, but in my project there is something very wrong that is giving some very strange errors
– V.Avancini
If any plugin is not conflicting with the jQuery, I don’t know what it could be.
– user98628
I’m pretty sure it’s conflict anyway, but I don’t know how to fix it
– V.Avancini