Definir_Intervalo_Datas
by caiubyfreitas
HTML
Data:
<input type="date" id="no-spin" onkeypress="return false" name="date" min="" max="">
CSS
#no-spin::-webkit-inner-spin-button {
-webkit-appearance: none;
}
input[type="date"] {
position: relative;
padding: 4px;
}
input[type="date"]::-webkit-calendar-picker-indicator {
color: transparent;
background: none;
z-index: 1;
}
input[type="date"]:before {
color: transparent;
background: none;
display: block;
font-family: 'FontAwesome';
content: '\f073';
width: 15px;
height: 20px;
position: absolute;
top: 7px;
right: 6px;
color: #999;
}
JavaScript
Date.prototype.yyyymmdd = function(days) {
var yyyy = this.getFullYear();
var mm = this.getMonth() < 9 ? "0" + (this.getMonth() + 1) : (this.getMonth() + 1); // getMonth() is zero-based
var dd = (this.getDate() < 10 ? "0" + this.getDate() : this.getDate()) + days;
return "".concat(yyyy).concat("-").concat(mm).concat("-").concat(dd);
};
var d = new Date();
var interval_min = d.yyyymmdd(0);
var interval_max = d.yyyymmdd(7);
document.getElementById("no-spin").setAttribute("min", interval_min);
document.getElementById("no-spin").setAttribute("max", interval_max);