Skip to content

Instantly share code, notes, and snippets.

@suissa
Created March 5, 2012 21:12
Show Gist options
  • Save suissa/1981134 to your computer and use it in GitHub Desktop.
Save suissa/1981134 to your computer and use it in GitHub Desktop.
Criação de jquery datepicker utilizando uma data inicial e data final, sendo a data final não podendo ser menor que a data inicial.
var dates = $( "#data_inicial, #data_final" ).datepicker({
dateFormat: 'dd/mm/yy',
defaultDate: "+1w",
changeMonth: true,
onSelect: function( selectedDate ) {
var option = this.id == "data_inicial" ? "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 );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment