FjongFasong
FjongFasong

Reputation: 41

How to change/remove a month from <input type="date"

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

Answers (1)

devil_coder
devil_coder

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

Related Questions