Mike Irving
Mike Irving

Reputation: 1628

jQuery UI Datepicker, set default start of day

We have a system where we instantiate many .datepicker objects

I know I can set the start date like so

$('.selector').datepicker('option', 'firstDay', 4); // i.e. Thursday

Is there a way of setting this value by default, for all subsequent .datepicker requests (without the need to have to specify the firstDay option at the point of execution?

Upvotes: 0

Views: 266

Answers (2)

Negi Rox
Negi Rox

Reputation: 3922

There is lots of options available with Jquery UI datepicker

$.datepicker.setDefaults({
    constrainInput: true,   // prevent letters in the input field
    minDate: new Date(),    // prevent selection of date older than today
    showOn: 'button',       // Show a button next to the text-field
    autoSize: true,         // automatically resize the input field 
    altFormat: 'yy-mm-dd',  // Date Format used
    firstDay: 4 // Start with Thursday
})

Upvotes: 3

Hary
Hary

Reputation: 5818

You can do it with $.datepicker.setDefaults( options ). Check here

$.datepicker.setDefaults({
  firstDay: 4,
});

Upvotes: 0

Related Questions