pixie123 pixie123 - 18 days ago 5
CSS Question

Disable select option if input is certain day

How can I disable a

select
option
field if day is a Saturday?

I have one
input
and one
select
.

<input type="text" name="date">11/15/2016

<select>
<option value="car">Car</option>
<option value="boat">Boat</option>
</select>


Here is my javascript:

if(???) {
$("option[value='boat']").attr("disabled", "disabled");
}


What should i put in the if statement if the
input
date
is a Saturday?

Answer
var today = new Date('2016-11-15');
if(today.getDay() == 6) {//6 is saturday
    ...// disable the option value
}
Comments