Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] problem z walidacja danych
Sebastian003
post
Post #1





Grupa: Zarejestrowani
Postów: 282
Pomógł: 2
Dołączył: 22.03.2007

Ostrzeżenie: (0%)
-----


Mam takowy kod - komunikat wyskakuje, oprócz ostatniego "ok" Co robię zle?

  1. <script type="text/javascript">
  2. function error(tekst) {
  3. if (errfound) return;
  4. window.alert(tekst);
  5. errfound = true;
  6. }
  7. function validate() {
  8. errfound = false;
  9. var bledy = "";
  10. with (document.forms[0]) {
  11. if (name.value == "") bledy += "Nie podałeś imienia. \n";
  12. if (surname.value == "") bledy += "Nie podałeś nazwiska.\n";
  13. if (phone.value == "") bledy += "Nie napisałeś telefonu. \n";
  14. if (ok.value == "") bledy += "Nie Wyrażiłeś zgody. \n";
  15. if (bledy != "") error(bledy);
  16. }
  17. return !errfound;
  18. }
  19. </script>


  1. <form id="MyForm" action="send3.php" method="post" name="MyForm" onsubmit="return validate();">
  2. <div >Imię:</div>
  3. <input id="name" class="mainform" type="text" value="" name="name" />
  4. <div >Nazwisko:</div>
  5. <input id="surname" class="mainform" type="text" value="" name="surname" />
  6. <div >Telefon:</div>
  7. <input id="phone" class="mainform" type="text" value="" name="phone" />
  8. <div >E-mail:</div>
  9. <input id="mail" class="mainform" type="text" value="" name="mail" />
  10. <input id="approve" type="checkbox" name="ok" />
  11. </form>


Ten post edytował Sebastian003 7.08.2013, 10:25:22
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 3.10.2025 - 19:50