Advertisement
Guest User

Untitled

a guest
May 25th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="pl">
  3. <head>
  4. <title>Kontakt</title>
  5. <meta charset="utf-8">
  6. <link rel="stylesheet" href="styles.css">
  7. </head>
  8.  
  9. <body>
  10. <h2 id="powitanie">Chciałbyś się skontaktować? Wyślij swoją wiadomość</h2>
  11. <form name="form" onsubmit="validate()">
  12. <label>
  13. Imię:
  14. <input type="text" name="imie" class="text" required/>
  15. </label>
  16. <label>
  17. Nazwisko:
  18. <input type="text" name="nazwisko" class="text" required/>
  19. </label>
  20. <label>
  21. Email:
  22. <input type="email" name="aemail" class="email" required/>
  23. </label>
  24. <label>
  25. Treść:
  26. <textarea name="pole" required></textarea>
  27. </label>
  28. <button type="submit">Wyślij wiadomość</button>
  29. </form>
  30.  
  31. <script>
  32. function validate(){
  33. var ctrl = 0;
  34. if(document.form.imie.value.length < 3){
  35. alert("Niepoprawne imie");
  36. ctrl++;
  37. }
  38. if(document.form.nazwisko.value.length < 3){
  39. alert("Niepoprawne nazwisko");
  40. ctrl++;
  41. }
  42. if(document.form.aemail.value.length < 6){
  43. alert("Niepoprawny adres");
  44. ctrl++;
  45. }
  46. }
  47. if(document.form.pole.value.length == 0){
  48. alert("Uzupełnij wiadomość");
  49. ctrl++;
  50. }
  51. if(ctrl==4){
  52. alert("Wiadomość nie mogła zostać wysłana. Popraw formularz");
  53.  
  54. }
  55. if(ctrl==0){
  56. alert("Wiadomość wysłana");
  57. }
  58. }
  59. </script>
  60. <article id="footer">
  61. <a href="index.html" title="powrot">Powrót</a>
  62. </article>
  63. </body>
  64. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement