0
왜이 기능이 작동하지 않는지 내 인생을 예측할 수 없습니다. 경고를 걸면 작동하지만 표시를 변경하려고 할 때 작동하지 않습니다.display = none을 (를) 함수에서 차단하려고 시도했습니다.
<script>
function validatesForm() {
var x=document.forms["MYPage"]["name"].value;
if (x == null || x == "")
{
document.getElementById("errorname").style.display="block";
return false;
}
}
</script>
</head>
<body>
<form name="MYPage">
Name:
<input type="text" name="name" />    <p id="errorname" style="color:red; display:none;">Please fill out this field</p>
<input type="submit" value="Validate!" onclick="validatesForm()">
</form>