Last active
September 17, 2017 01:26
-
-
Save tahafarooqui/e220f815defce803395af9bf94682045 to your computer and use it in GitHub Desktop.
Jquery datepicker restrict dates in second date field based on selected date in first date field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(".startDate").datepicker({ | |
minDate: 0, | |
onSelect: function (selected) { | |
var dt = jQuery(this).datepicker("getDate"); | |
dt.setDate(dt.getDate() + 1); | |
jQuery(".endDate").datepicker("option", "minDate", dt); | |
jQuery(".endDate").datepicker("option", "dateFormat", "dd.mm.yy"); | |
jQuery(".endDate").datepicker("setDate", dt); | |
//Dateformat | |
jQuery(".startDate").datepicker("option", "dateFormat", "dd.mm.yy"); | |
} | |
}); | |
jQuery(".endDate").datepicker({ | |
minDate: 0, | |
onSelect: function (selected) { | |
var dt = jQuery(this).datepicker("getDate"); | |
dt.setDate(dt.getDate() - 1); | |
//Dateformat | |
jQuery(".endDate").datepicker("option", "dateFormat", "dd.mm.yy"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: Make sure, your date picker code should be in this code.
jQuery(document).ready(function(){
//Your Date picker Code
});