I have 2 datepickers. #datepicker0 and #datepicker1 and the following code to check if the date_from is after date_to:
$('#datepicker0').datepicker({
  dateFormat: 'yy-mm-dd'
});
var valeDate = {
  dateFormat: 'yy-mm-dd',
  onSelect: function() {
    if ($('#datepicker0').val() > $(this).val()) {
      alert("Date problem");
      $(this).val(null)
    }
    $(this).change();
  }
}
$("#datepicker1").datepicker(valeDate).on("change", function() {
  display("Change event");
I would like to remove the parameter #datepicker0 from the onSelect function in order to make the function reusable.
Could anyone show me how to make it?
 
    