galvin Posted December 23, 2010 Share Posted December 23, 2010 New to JQuery... If I have this in the HEAD of my document (which works fine to display a blank field that, if you click, pops up a datepicker set to today's date)... <script> $(function() { $( "#datepicker" ).datepicker({ dateFormat: 'mm/dd/yy' }); }); </script> How would I implement this "Method" below? .datepicker( "setDate" , 11-11-2011) Basically, when someone goes to this page with the DatePicker, I want the date 11-11-2011 to appear in the field/datepicker by default. It sounds like this "setDate" Method is what I should use to do this, but I can't figure out where exactly to put this code (i.e. in the same script tags above, or somewhere else on the page), and need to know exactly how to write it. Can anyone help? Quote Link to comment Share on other sites More sharing options...
Xtremer360 Posted December 23, 2010 Share Posted December 23, 2010 From my experiences its best not to use dashes use the backslash. And it should go right below dateFormat. .datepicker( "setDate" , 11/01/2011 ) Quote Link to comment Share on other sites More sharing options...
.josh Posted December 24, 2010 Share Posted December 24, 2010 doing 11-11-2011 should be fine, just wrap it in quotes. And yeah, since you want it to be the "defaule" date, call it right after the first code you have (the dateFormat). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.