Thank you so much for the response and the solution to my problem. I'm sure I read most of the documentation but didn't think to check the Events or Methods tab once I had got to the bottom of the options page - which is quite a long page once everything is expanded. I think the documentation could be improved if your example was made into a demo, considering this usage must be quite common.
On Jun 10, 8:20 am, Ca-Phun Ung <[email protected]> wrote: > On Wed, Jun 10, 2009 at 12:27 AM, Luke <[email protected]> wrote: > > > I'm getting really frustrated with the datePicker. > > Sorry to hear this. > > > > > > > I'm trying to create a booking form with "Date From" and "Date To", > > the two date fields are given an initial value which sets the "Date > > From" field to be 2, 3 or 4 days in the future, and the "Date To" > > field is set at the date of the last available date for booking. If a > > "Date From" is picked, then the user should not be able to pick a > > "Date To" before this date, and vice versa. > > > Lots of these datePicker scripts allow the developer to do this simply > > using a few settings. But for me to do it with datePicker I have to > > mess around with initial minDate and maxDate settings, then modify > > those settings for the other datePicker control if a date is selected > > on the other. Fine, I think I can do this using onchange/onblur events > > or whatever useful features jQuery has. > > Yes. This is possible. Try the onSelect event, see: > > http://jqueryui.com/demos/datepicker/#event-onSelect > > > > > But why oh why are the minDate and maxDate settings so difficult to > > set? They require a date to in the following format, the default > > format generated by "new Date(2009, 7 - 1, 9)": > > Tue Jun 09 2009 17:01:06 GMT+0100 (GMT) > > // (what is wrong with the month value that means it needs the -1 to > > generate the intended month? why does month start at 0 when day starts > > at 1?!) > > I agree, it is a bit inconsistent in that sense. But is is consistent with > how JavaScript handles dates natively? > > > > > Or you can put the dates in some strange custom syntax which allows > > you to specify a date by adding or subtracting days/weeks/months/ > > years. > > Because of this minDate and maxDate is more powerful as you could specify > relative dates. I like this feature. > > > > > Wouldn't it just be simpler to use the date format specified in > > dateFormat? Or at least in a format that allows the value of one date > > field to be useful to another date field. Well I suppose the reason > > for that is because the dateFormat setting isn't very accurate either. > > Why does dd/mm/yyyy equate to 09/06/20092009? Yet dd/mm/yy equates to > > 09/06/2009. Surely it should be 09/06/2009 and 09/06/09 respectively. > > Or it could follow the same formatting as the php/etc date functions. > > > Which genius thought of that? God almighty talk about making life > > difficult for anyone who dares to use it! Are there plans to improve > > the datePicker? Because at the moment I am stumped to work out how the > > hell I am going to get it to do one of the most basic requirements of > > a datePicker. > > Yes, there is a re-factor on the way, see:http://wiki.jqueryui.com/Datepicker > > > > > Basically I need to work out how to convert "09/06/2009" to "2009, 7 - > > 1, 9", so I can convert it to "Tue Jun 09 2009 17:01:06 GMT+0100 > > (GMT)", so I can pass it to minDate or maxDate. But I'm not hopeful > > because I can't even get this to work. > > Here's an example: > > $(function(){ > $('#dateFrom').datepicker({ > dateFormat: 'dd/mm/yy', > onSelect: function(dateText, inst) { > console.log(inst); > $('#dateTo').datepicker('option','minDate', new > Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay)); > } > }); > $('#dateTo').datepicker({ > dateFormat: 'dd/mm/yy', > onSelect: function(dateText, inst) { > $('#dateFrom').datepicker('option','maxDate', new > Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay)); > } > }); > > }); > > I hope this helps. We really appreciate all the feedback and I see a lot of > constructive criticisms in your post, which is good. We're trying to improve > the Datepicker in our next re-factor so any ideas for improvements are more > than welcomed. > > Thanks! > > -- > Ca-Phun Ung > +http://yelotofu.com > + hongkong, zce, jquery, jqueryui, php, css, html --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~---
