Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datepicker jQuery UI ... set language

I tried to set Datepicker, like this:

<script type="text/javascript">
    $.datepicker.setDefaults($.datepicker.regional['nl']);
    $(function () {
        $("#tbDateDiagnostic").datepicker({
            numberOfMonths: 2,
            showButtonPanel: true,
            ateFormat: 'dd/mm/yy'
        });

        $("#tbDateSend").datepicker({
            numberOfMonths: 2,
            showButtonPanel: true,
            dateFormat : 'dd/mm/yy'
        });
    });
</script>

But all the time, the datepicker is in French and not in Dutch.

Did I do something wrong?

like image 595
Kris-I Avatar asked Mar 16 '11 22:03

Kris-I


People also ask

What is jQuery UI datepicker?

The jQuery UI Datepicker is a highly configurable plugin that adds datepicker functionality to your pages. You can customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily.

How to change language of datepicker widget text in UI?

jQuery UI datepicker by default show widget text content in English language but you can change it any other language easily. For this, you need to load language script file on your web page and point it to the datepicker widget. Download and Include.

How do I localize my datepicker?

Datepicker provides support for localizing its content to cater for different languages and date formats. Each localization is contained within its own file with the language code appended to the name, e. g., jquery. ui. datepicker-fr. js for French. The desired localization file should be included after the main datepicker code.

How do I create a datepicker on an <input type="date>?

Creating a datepicker on an <input type="date"> is not supported due to a UI conflict with the native picker. An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field.


2 Answers

I'm guessing you forgot to include the localisation file:

<script src="https://jquery-ui.googlecode.com/svn-history/r3982/trunk/ui/i18n/jquery.ui.datepicker-nl.js"></script>

You may find other localisation files here: https://github.com/jquery/jquery-ui/tree/master/ui/i18n

Here's a demo: http://jsfiddle.net/repw4/418/

like image 91
William Niu Avatar answered Oct 13 '22 02:10

William Niu


keith-wood is a good site with detailed examples. Try this:

$.localise('js/jquery.datepick', 'nl'); 
$('#tbDateSend').datepick('option', $.datepick.regional['nl']); 
$.datepick.setDefaults($.datepick.regional['']); 
like image 27
Assaf Adato Avatar answered Oct 13 '22 03:10

Assaf Adato