1
我有一個Javascript數據驗證程序,它工作正常,它基本上顯示特定日期的額外信息,例如,它在哪一天以及其他信息。Javascript:數據驗證表格
我的問題是我不知道如何放入HTML標記。
這裏也是我的任務截圖:
var canvas;
canvas = openGraphics();
var day;
day=prompt("Please enter your day of birth");
var month;
month = prompt("Please enter your month of birth");
var year;
year = prompt("Please enter your year of birth");
var date;
date = new Date(year, month-1,day);
if(true){
if(date.getFullYear()== year)
{
}
if(date.getMonth()== month-1)
{
}
if(date.getDate()== day)
{
}
else{
alert("Invalid Date");
}
}
canvas.setFont("Palatino Linotype", "24px", Font.PLAIN);
canvas.setColor("blue");
canvas.drawString("Full DOB:", 10, 10);
canvas.drawString(date, 100, 10);
canvas.paint();
我試圖HTML到目前爲止,都是錯誤的,我需要有人來告訴我如何實現我上面的代碼爲HTML格式:
<html>
<head>
<title>
Date Validation
</title>
<script>
function checkdate(){
var year = document.getElementById('year').value;
var month = document.getElementById('month').value;
var day = document.getElementById('day').value;
var date = new Date(year, month-1,day);
if(true)
{
if(date.getFullYear()== year)
if(date.getMonth()== month-1)
if(date.getDate()== day)
}
else{
alert("Invalid Date");
}
</script>
<body>
<h1>Data Validation</h1>
<p> This page will be used to provide information on the specific date that you enter below. </p>
<form>
Day:
<input type = "text" input id="day" onchange = "checkdate();>
</form>
<form>
Month:
<input type = "text" input id="month" onchange = "checkdate();>
</form>
<form>
Year:
<input type = "text" input id="year" onchange = "checkdate();">
</form>
<form>
<input type="submit" value="Validate Date">
</form>
</body>
</html>