Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have two dates, Start date and End date. I need to validate the the end date should not greater than the start date.

need to clear (previous start date value) the date value when ever we change the date.

  • case 1# [ First time] start date - 23-Nov-2013 End date - 24-Nov-2013

now i changed the start date as -25-Nov-2013, but end date enabled the the 24-Nov-2013 (start previous value) on wards instead of 26-Nov-203.

So, i need to clear the value when ever i change the date.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
256 views
Welcome To Ask or Share your Answers For Others

1 Answer

Actually, what that 27/11/2013 represents is the current Date. Which will not get updated unless you write it on changeDate event.

So you have to do like

  1. Bind the start date, with changeDate event.
  2. Increment the selected date in start.
  3. Again set back the incremented date.
  4. Now update this to end Date using update method

    $('#end').datepicker('update', toDate);

Finally, you code will be like

$('#start').datepicker({}).on('changeDate', function (ev) {
    var toDate = ev.date;
    toDate.setDate(toDate.getDate() + 1);
    $('#end').datepicker('update', toDate);
});
$('#end').datepicker({});

JSFiddle


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...