<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
var x = getElementById("test");
if (x == "") {
alert("Name must be filled out");
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="/action_page.php" onsubmit="return validateForm()" method="post">
Name: <input type="text" name = "nameTest" id ="test">
<input type="submit" value="Submit">
</form>
</body>
</html>
在控制台中显示: 您收到的输入为: nameTest =
为什么名称标签包含在输入中?