我有一份提前预订表格,其中包含提交日期<input type=" date">
当用户输入上一个日期时,它应显示错误。
HTML
<form name="banquetbooking" id="banquetbooking" method="post" onsubmit="return banquetbookval()">
<input type="date" name="selectdate" id="selectdate" class="form-control" required><br>
<input type="submit" name="book" class="form-control" value="Book">
javascipt的
function banquetbookval() {
var seldate = document.getElementById("selectdate");
var today = new date();
if (seldate <= today){
alert ("Enter a valid date");
return true;
}else {
alert("Your booking is registered, we will call you within 24 hours");
return false;
}
}
应该只使用javascript
答案 0 :(得分:0)
要获取日期值,您必须将变量更改为
var seldate = document.getElementById("selectdate").value;
它会正常工作