Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] walidacja form problem
tenloginjestzaje...
post
Post #1





Grupa: Zarejestrowani
Postów: 358
Pomógł: 1
Dołączył: 20.07.2014

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


Witam
próbuje zrobić walidację formularza ( wszystkie trzy pola wymagane ), bezskutecznie:
  1. <form method="post" id="form" name="form" onsubmit="return validation()">
  2. Treść:
  3. <textarea id="text" name="text"></textarea>
  4. E-mail:
  5. <input type="text" name="mail" id="mail" />
  6. Imię:
  7. <input type="text" name="user" id="user" />
  8. <input type="submit" name="submit" class="button" value="Dodaj post" id="submit" />
  9. </form>
  10.  
  11.  
  12.  
  13. <script>
  14. function validation() {
  15. var a = document.form.user.value;
  16. var b = document.form.mail.value;
  17. var c = document.form.text.value;
  18. if (a == "" || b == "" || c == "")
  19. {
  20. alert("puste pola");
  21. return false;
  22. }
  23. else
  24. {return true};
  25. }
  26. </script>


dzięki za wskazanie błędu.

Ten post edytował tenloginjestzajety 13.05.2017, 12:53:06
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: 23.08.2025 - 10:35