6

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
  • 177,207
  • 343
  • 852
  • 1,351

2 Answers2

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

    /* your other function code here */

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

Similar questions:

H2O
  • 21
  • 3