Mam takowy kod - komunikat wyskakuje, oprócz ostatniego "ok" Co robię zle?
<script type="text/javascript">
function error(tekst) {
if (errfound) return;
window.alert(tekst);
errfound = true;
}
function validate() {
errfound = false;
var bledy = "";
with (document.forms[0]) {
if (name.value == "") bledy += "Nie podałeś imienia. \n";
if (surname.value == "") bledy += "Nie podałeś nazwiska.\n";
if (phone.value == "") bledy += "Nie napisałeś telefonu. \n";
if (ok.value == "") bledy += "Nie Wyrażiłeś zgody. \n";
if (bledy != "") error(bledy);
}
return !errfound;
}
</script>
<form id="MyForm" action="send3.php" method="post" name="MyForm" onsubmit="return validate();"> <input id="name" class="mainform" type="text" value="" name="name" /> <input id="surname" class="mainform" type="text" value="" name="surname" /> <input id="phone" class="mainform" type="text" value="" name="phone" /> <input id="mail" class="mainform" type="text" value="" name="mail" /> <input id="approve" type="checkbox" name="ok" />