我想在用户选择日期时显示某些内容。这是我的示例html代码。但这不起作用。
<head>
<script>
document.getElementById("dateInput").select()=function(){whatsTheDay};
function whatsTheDay(){
document.getElementById("err").innerHTML="you enter a date";}
</script>
</head>
<body>
<form>
<input type="date" id "dateInput" name = "brthdate" />
<input type="submit" id = "submit" name = "submitdt" onclick="sumitable"/>
</form>
<p id = "err"></p>
</body>
</html>
答案 0 :(得分:3)
<head>
<script>
document.getElementById("dateInput").select()=function(){whatsTheDay};
function whatsTheDay(){
document.getElementById("err").innerHTML="you enter a date";}
</script>
</head>
<body>
<form>
<input type="date" id "dateInput" onchange="whatsTheDay()" name = "brthdate" />
<input type="submit" id = "submit" name = "submitdt" onclick="sumitable"/>
</form>
<p id = "err"></p>
</body>
</html>