[datepicker] Restrict dynamically dates

[datepicker] Restrict dynamically dates

Hello guys,
I need to be able to select a date range so I have created 2 datepickers using UI.datepicker and now I'd like to restrict the available values.
How can I force the from_date not to be after the to date and vice-versa?


Here my last try

  1. $('#datepicker_from').datepicker({onSelect: function(dateText) { $('#datepicker_to').datepicker('option', 'minDate', new Date(dateText));}});

but it doesn't do anything.

Thanks and have a nice weekend

Sig