在输入字段中,我只想添加年龄超过18岁的那些人
输入id =“ txtDOB”类型=“文本” name =“ txtDOB”>
答案 0 :(得分:0)
您将不得不编写一些JS
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear()+18;
if(dd<10){
dd='0'+dd
}
if(mm<10){
mm='0'+mm
}
today = yyyy+'-'+mm+'-'+dd;
document.getElementById("txtDOB").setAttribute("max", today);