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

I am trying to create a calendar in which the month of April cannot be selected. Walked around with no luck.

(The first question is here, if there is something incomprehensible, just ask me and it hurts to try to be more specific too.) :)

+4
source share
1 answer

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

+1
source

Source: https://habr.com/ru/post/1676823/


All Articles