eng_mazzy
eng_mazzy

Reputation: 1049

Error in localize DatePicker

I'm trying to localize jquery datepicker but since I'm not an expert in jquery I get an error and I don't know how to fix it.

Error

TypeError: 'undefined' is not an object (evaluating '$.ui.datepicker.regional')

Here is the code of datepicker

calendar.js

$(function() {
    $( ".from" ).datepicker({
      defaultDate: "+1w",
      dateFormat: "dd/mm/yy",
      changeMonth: true,
      numberOfMonths: 1,
      onClose: function( selectedDate ) {
        $( ".to" ).datepicker( "option", "minDate", selectedDate );
      }
  });
    $( ".to" ).datepicker({
      defaultDate: "+1w",
      dateFormat: "dd/mm/yy",
      changeMonth: true,
      numberOfMonths: 1,
      onClose: function( selectedDate ) {
        $( ".from" ).datepicker( "option", "maxDate", selectedDate );
      }
    });
  });

and the localization

<script src="//jquery-ui.googlecode.com/svn-history/r3875/branches/labs/datepicker2/ui/i18n/jquery.ui.datepicker-it.js" ></script>

Both of them come after the following code

<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

Upvotes: 0

Views: 2676

Answers (1)

Shaunak D
Shaunak D

Reputation: 20636

Refer this Link - Datepicker Localize

Demo Fiddle

$(function() {
    $( ".from" ).datepicker( $.datepicker.regional[ "it" ] );
    $( ".to" ).datepicker( $.datepicker.regional[ "it" ] );
});

Use the below script tag for reference.

 <script src="http://jquery-ui.googlecode.com/svn/tags/1.8.20/ui/i18n/jquery.ui.datepicker-it.js" ></script>
  • You need to include $.datepicker.regional[ "it" ] to apply localize settings.

Updated Demo

Upvotes: 2

Related Questions