I am trying to create date functionality using jquery on start date and end date controls. i want to select start date and when coming to end date before the start date , the previous date will come as disable my code is below.
$( "#" + TxtStrtDate,"#" + TxtExpDte" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
var option = this.id == "abc" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
what is the mistake in my code please suggest.
Since you mentioned that these were server controls, I assume you are using ASP.NET. If this is the case and you are using MasterPages, MasterPages mangle the id of the control so you have to do the following:
Otherwise, you have an extra ” in your selector and your ids need to be within the quotes unless they are actually javascript variables:
should be changed to:
Edit:
Per your comment, it seems that you want to use the date range version of the jquery datepicker. For that you will have to do the following:
Checkout the date range demo on the jquery ui site for more information.