Enable Datepicker only when first field has a value
Posted
by
Syed Abdul Rahman
on Stack Overflow
See other posts from Stack Overflow
or by Syed Abdul Rahman
Published on 2011-01-01T05:57:58Z
Indexed on
2011/01/01
6:53 UTC
Read the original article
Hit count: 371
Right now, the End Date selection is disabled. I want to only enable this when a Start Date is selected.
if( $('#datepicker1').val().length === 0) {
$('#datepicker2').datepicker("disable");
} else {
$('#datepicker2').datepicker("enable");
}
This clearly does not work. If I insert value = 'random date' into my first input field, it works fine. I'm not too sure on how do this. Clearly not as easy as I had hoped.
My other problem, or hope, is to disable the dates including and before the first selection. You know, pick Start Date, and every date before and said date for the next picker would be disabled. But that is a whole other problem.
© Stack Overflow or respective owner