Reputation: 41
I'm trying to make a calendar where the month April can't be picked. Been searching around without luck.
(First question here, if there anything unclear just ask me and ill try too be more specific.) :)
Upvotes: 4
Views: 466
Reputation: 1135
You can do something like below
<input type="date" name="selectDate" id="selectDate" />
And
var selectDate = document.getElementById("selectDate");
selectDate.onchange = function(){
var d = document.getElementById("selectDate").value;
var dObject = new Date( d );
if (dObject.getMonth() + 1 == 4) {
alert('You cant select month of April');
return false;
} else {
return true;
}
}
JSfiddle link here
Upvotes: 1