확인란의 유효성을 검사하는 폼을 만들려고합니다. 나는 새로운 페이지로 이동하기 전에 박스를 체크하고 submit 버튼을 눌러야한다는 생각이다. 그래서 나는 체크 박스를 가지고 있으며 그것을 검사 할 수있는 함수가 있지만 페이지를로드 할 수는 없다. 두 페이지를 여기에 로컬로 저장하고 올바른지, 그래서 그것은 유효성 검사 기능에 문제가 있어야합니다. 어떤 도움을 주셔서 감사합니다!확인란의 유효성을 검사하고 새 페이지에 연결
<!DOCTYPE html>
<html>
<head>
<title>AcceptTerms</title>
</head>
<body>
<h1>Before proceeduing you must agree to our terms and conditions.</h1>
<br>
<h3>Do you accept our terms?</h3>
<form>
<p><input type="checkbox" name="checkbox" value="Yes, I accept" />Yes, I accept</p>
<input type="button" value="Submit" onclick="confirmTerms()">
</form>
<br>
<button onclick="openDecline()">Decline Terms</button>
<script>
function openDecline()
{
window.open("declinepage.html");
}
</script>
<br>
<script type="text/javascript">
function confirmTerms() {
if (document.forms[0].checkbox.checked==false {
alert("You did not select a box.");
return false
}
if (document.forms[0].checkbox.checked) {
window.location.href = "acceptpage.html";
}
if (document.forms[0].checkbox.checked=false) {
window.location.href = "declinepage.html";
}
</script>
</body>
</html>
이것은 내가 필요한 것입니다! 도와 주셔서 감사합니다! 내가 어디에서 잘못되었는지 알고 싶습니다. 체크 박스에 대한 정보를 얻기 위해 getElementById 메소드를 추가 한 것 같습니다. 그 맞습니까? – user3247096
@ user3247096 예 – Myth