jqueryjquery-mobiledatebox

Setting default date in Datebox in textfield and calendar?


I have a date field from datebox (from dev.jtsage.com) that I am using with jquery mobile

1 - How do I set the default value in the text box and the calendar to todays date? Also have to disable all the previous dates.

I Have tried

var defaultPickerValue = new Date();
$('#mydate').datebox({'defaultValue': defaultPickerValue});

But this doesn't set the value in the text field. What should I do to disable all the previous dates?

2 - Secondly, I have a 2 date fields. On selecting date on first field the date in second field should set automatically. How do I do it?


Solution

  • To disable all the previous dates, try this:

    $("#mydate").datebox({"mode":"calbox", "useNewStyle":true, "afterToday":true});
    

    And to set defaultValue, please look at http://dev.jtsage.com/jQM-DateBox/api/ >> Common Options

    defaultValue    Default value for the date - e.g. [2001,1,1] or 13:42   false   Array/String    -ALL