Salman Virk
Salman Virk

Reputation: 12307

How to set Date in JQuery?

Using JQuery, I want to load startDate in DatePicker.

$('#myId').datepicker({ minDate: '-100D', maxDate: '+145D', startDate: new Date(2011,0,4) });

where myId is an input field. MinDate, maxDate both are working fine but startDate is not working. Currently, it is showing today's date.

Upvotes: 0

Views: 419

Answers (3)

Peter Örneholm
Peter Örneholm

Reputation: 2858

You are looking for defaultDate, and this is actually jQuery UI, not just jQuery.

Example:

$('#myId').datepicker({ minDate: '-100D', maxDate: '+145D', defaultDate: new Date(2011,0,4) });

Upvotes: 2

ionoy
ionoy

Reputation: 985

The property yo uare trying to set is actually called 'defaultDate' not 'startDate'. Also, keep in mind, that 'defaultDate' should be in range (minDate, maxDate).

Upvotes: 1

brian-d
brian-d

Reputation: 803

It doesn't look like startDate is an option for the jqueryUI date picker: Datepicker (Click options tab). I think you want defaultDate

Upvotes: 2

Related Questions