Reputation: 1002
I have problem with datepicker
setDate
option (I need to use server date in datepicker). I have display current date from server in that format (html source):
<div id="cur-date">27/11/2013</div>
In jquery script I try to set the setDate
using this code:
$('#date_from, #date_to').datepicker({
beforeShowDay: noWeekendsOrHolidays,
defaultDate: '+1d',
minDate: '+1d'
}).datepicker('setDate', '#cur-date');
But it didn't work. Any suggestion what is wrong?
Upvotes: 0
Views: 802
Reputation: 10378
first use text() not val()
val() is use for input type
$('#date_from, #date_to').datepicker({
beforeShowDay: noWeekendsOrHolidays,
dateFormat: "mm/dd/yy"
}).datepicker("setDate", $("#cur-date").text());
Upvotes: 1
Reputation: 142
Use datepicker with these parameters
$('#date_from, #date_to').datepicker({
format: 'mm/dd/yy',
autoclose: true,
forceParse:true,
pickerPosition: "bottom-left",
startDate: $("#cur-date").text()
});
Upvotes: 0
Reputation: 3960
Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d"
represents one month
and seven days
from today
.Since you are added +1d it does not show the current date. For example 2 represents two days from today and -1 represents yesterday.
$('#date_from, #date_to').datepicker({
defaultDate: '+1d',
minDate: '0'
}).datepicker('setDate', '#cur-date');
Try removing the `minDate: '+1d'` or try commenting that part or even changing it to 0.
Working fiddle
Upvotes: 0