bootstrap datepicker locale / language不起作用

时间:2016-09-20 03:47:04

标签: jquery datepicker

JS和css已添加 -

<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="css/css.css">
<link rel="shortcut icon" href="foto/logo.png" />
<link href='css/hover.css' rel='stylesheet' media='all'>

<script src="script/jquery.min.js"></script>
<script src="script/script.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/locales/bootstrap-datepicker.id.min.js" charset="UTF-8"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker3.css"/>

Javascript代码 -

<script>
$(document).ready(function(){
  var date_input=$('input[name="datepicker"]'); //our date input has the name "date"
  var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
  var options={
    format: 'dd-mm-yyyy',
    container: container,
    todayHighlight: true,
    autoclose: true, 
    daysOfWeekDisabled: "0",
    daysOfWeekHighlighted: "0",
    language: "id",
    locale: "id",
  };
  date_input.datepicker({options});
})
</script>

HTML -

<input class="form-control" id="date" name="datepicker" placeholder=" -- (tahun/bulan/tanggal) -- " type="text"/>

bootstrap datepicker locale / languange不工作
我错过了什么吗?

bootstrap datepicker locale / languange不工作
我错过了什么吗?

bootstrap datepicker locale / languange不工作
我错过了什么吗?

bootstrap datepicker locale / languange不工作
我错过了什么吗?

3 个答案:

答案 0 :(得分:2)

您遗失了jquery.jsbootstrap.min.css,而且以下行还有语法错误:

date_input.datepicker({options});

应该是:

date_input.datepicker(options); 

尝试以下工作演示:

&#13;
&#13;
$(document).ready(function(){
 var date_input=$('input[name="datepicker"]'); //our date input has the name "date"
  var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
  var options={
    format: 'dd-mm-yyyy',
    container: container,
    todayHighlight: true,
    autoclose: true, 
    daysOfWeekDisabled: "0",
    daysOfWeekHighlighted: "0",
    language: "id",
    locale: "id",
  };
  date_input.datepicker(options);  
});
&#13;
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/locales/bootstrap-datepicker.id.min.js" charset="UTF-8"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker3.css"/>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"/>

<input class="form-control" id="date" name="datepicker" placeholder=" -- (tahun/bulan/tanggal) -- " type="text"/>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

你必须将Jquery包含在

之上
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js"></script>

然后是你的js和css

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/locales/bootstrap-datepicker.id.min.js" charset="UTF-8"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker3.css"/>

希望这会对你有所帮助。

答案 2 :(得分:0)

尝试找到合适的时区 here

例如添加

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/locale/id.js"></script>