これが非常にばかげていることは理解していますが、タグ間のコードが機能しません。
簡単な HTML 登録フォームがあります。そして、js コードは、入力が空であることを簡単にチェックします。
function validate()
{
if (document.forms.registration.email.value == "")
{
alert("You must provide an email address.");
return false;
}
else if (document.forms.registration.password1.value != document.forms.registration.password2.value)
{
alert("You must provide the same password twice");
return false;
}
else if (!document.forms.registration.agreement.checked)
{
alert("You must agree to ours terms and conditions");
return false;
}
return true;
}
何らかの理由で、ブラウザーはこのコードを無視し、フォームが空であってもフォームを送信します。
編集:(OPコメントに基づいて追加)
<form action="process.php" id="registration" method="get" onsubmit="return.validate();">
<!-- Other child elements of the form -->
</form>