Jquery datepicker MVC的区域问题

时间:2017-05-08 16:27:56

标签: jquery datepicker

我正在尝试解决区域问题(意大利),但没有成功,我视图中的脚本是:

    <script type="text/javascript"></script>
<script src="~/Scripts/jquery-ui-i18n.min.js"></script>
<script src="~/Scripts/jquery-ui-i18n.js"></script>
<script>
        $(function () {
            $('.datefield').datepicker({
                startDate: "-3d",
                maxViewMode: 3,
                todayBtn: "linked",
                multidate: false,
                autoclose: true,
                todayHighlight: true,
                toggleActive: true,
                FormData: "yyyy-MM-dd",
                regional:"it"
            });
            //$.datepicker.setDefaults($.datepicker.regional['it']);
            //$('.datefield').datepicker();
        });
</script>

但是datepicker是英文的。我不明白。谢谢

1 个答案:

答案 0 :(得分:3)

您需要确保包含jQuery,jQueryUI和jQueryUI的i18n库,所有这些都按正确的顺序排列。试试这个:

&#13;
&#13;
$(function() {
  $('.datefield').datepicker({
    startDate: "-3d",
    maxViewMode: 3,
    todayBtn: "linked",
    multidate: false,
    autoclose: true,
    todayHighlight: true,
    toggleActive: true,
    FormData: "yyyy-MM-dd"
  });
  $.datepicker.setDefaults($.datepicker.regional['it']);
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.9.2/i18n/jquery-ui-i18n.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.min.css" />
<input type="text" class="datefield" />
&#13;
&#13;
&#13;