Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>sprawdzenie, czy dana wejściowa odpowiada konstrukcji kodu pocztowego </title>
  4. <meta charset="UTF-8">
  5. </head>
  6. <body>
  7. <form>
  8. Podaj kod pocztowy <input id="input1" type="text"/><br/><br/>
  9. <button type="button" onclick="sprawdzKod();">POBIERZ</button><br/><br/>
  10. </form>
  11. <br/>
  12. <br/>
  13. <div id="div1"></div>
  14. <script>
  15. function sprawdzKod()
  16. {
  17. var INPUT1=document.getElementById("input1");
  18. var DIV1=document.getElementById("div1");
  19.  
  20. var wzorzecKodu=/^\d{2}-\d{3}$/;
  21. var kod=input1.value;
  22. if (wzorzecKodu.test(kod))
  23. DIV1.innerHTML="Format kodu pocztowego " + kod + " : prawidłowy";
  24. else
  25. alert("Proszę wprowadzić prawidłowo kod pocztowy, np. 18-400 !";);
  26. }
  27. </script>
  28. </body>
  29. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement