7

I am using a jquery ui datepicker. I want to add some validation so it only allows people to choose Saturdays instead of any date.

I could validate after the fact but thought it would be slicker to have the datepicker do the upfront validation by only enabling Saturday dates.

leora
  • 188,729
  • 360
  • 878
  • 1,366

2 Answers2

17
$("#test").datepicker(
    {
        beforeShowDay: function(date){
          if(date.getDay() == 6){
                return [true];
            } else {
                return [false];
            }
        }
    }
);
Paté
  • 1,914
  • 2
  • 22
  • 33
0
beforeShowDay: function (date) {

    /* your other function code here */

    if (date.getDay() == 6) {
        return [true, ''];
    } else {
        return [false, ''];
    }
}

Similar questions:

H2O
  • 23
  • 5