Web Development with jQuery®

(Elliott) #1

Localizing the Datepicker (^) ❘ 397


Changing the Starting Weekday


In some places in the world, the calendar begins with Monday and ends with Sunday. Whichever
day you want to use as the starting weekday is also customizable via the firstDay option. The fol-
lowing script, Example 16-6, demonstrates how to change the starting weekday:

$(document).ready(
function()
{
$('input#exampleDate').datepicker({
changeMonth : true,
changeYear : true,
minDate : new Date(1900, 1, 1),
maxDate : new Date(2020, 12, 31),
yearRange : "1900:2020",
dateFormat : "dd/mm/yy",
firstDay : 1
});

$('div.exampleDate img').click(
function()
{
$(this)
.prev('input')
.focus();
}
);
}
);

In the preceding script, the firstDay option changes the starting calendar day from Sunday (which is
number 0) to Monday (which is number 1). Figure 16-6 shows the result of the change.

FIGURE 16-6


http://www.it-ebooks.info

Free download pdf