Witam mam problem z walidacja formularza w js.
kod formularza:
Witaj.
Twój podpis:
Wybierz język:
Polski English Français
Treść:
[/code] send.php:
[code] <?php include(“top.php”); echo ’
‘; if (count($_POST)) { ////////// USTAWIENIA ////////// $email = ‘’; // Adres e-mail adresata $subject = ‘kontakt ze strony’; // Temat listu $message = ’ Dziękujemy za wysłanie wiadomości.’; // Komunikat $error = ’ Wystąpił błąd podczas wysyłania formularza. '; // Komunikat błędu $charset = ‘iso-8859-2’; // Strona kodowa ////////////////////////////// $head = “MIME-Version: 1.0\r\n” . “Content-Type: text/plain; charset=$charset\r\n” . “Content-Transfer-Encoding: 8bit”; $body = ‘’; foreach ($_POST as $name => $value) { if (is_array($value)) { for ($i = 0; $i < count($value); $i++) { $body .= “$name=” . (get_magic_quotes_gpc() ? stripslashes($value[$i]) : $value[$i]) . “\r\n”; } } else $body .= “$name=” . (get_magic_quotes_gpc() ? stripslashes($value) : $value) . “\r\n”; } echo mail($email, “=?$charset?B?” . base64_encode($subject) . “?=”, $body, $head) ? $message : $error; } echo ’
'; include(“footer.php”); ?>
scripts.js:
function czyWypelnione(pole) {
if (pole.value == "") {
document.getElementById("i" + pole.id).innerHTML = "To pole jest wymagane!";
return false;
}
else {
document.getElementById("i" + pole.id).innerHTML = "";
return true;
}
}
window.onload = function() {
document.getElementById("contactform").onsubmit = function() {
if (czyWypelnione(this.podpis) && czyWypelnione(this.jezyk) && czyWypelnione(this.tresc)) {
return true;
}
else {
return false;
}
}
}