The problem I have is the following:
I would like to get the Text from
<div id="article-pubdate">2013-07-27</div>
as a defaultDate into
<input type='text' id='datepicker'>
However, this doesn't work:
$(function() {
$('#datepicker').datepicker({
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
yearRange: '1990:2013',
});
$( "#datepicker" ).datepicker( "option", "defaultDate", new Date($("#article-pubdate").text().replace(/\-/g, ',')));
});
setDate works, but doesn't let me edit the date afterwards, it always submits the date that is in #article-pubdate, so that is not an option:
$(function() {
$('#datepicker').datepicker({
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
yearRange: '1990:2013',
});
$('#datepicker').datepicker('setDate', new Date($("#article-pubdate").text().replace(/\-/g, ',')));
});
Can you guys tell me what's going on?