Advertisement
Guest User

asdf

a guest
Mar 28th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.78 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta charset="UTF-8"/>
  5.         <script>
  6.             function fcode(x){
  7.                 var pattern = /^\d{2}\-\d{3}$/;
  8.                 if (!x.value.match(pattern)) {
  9.                     alert("Niepoprawny format kodu pocztowego.");
  10.                     x.value = "";
  11.                 }
  12.             }
  13.  
  14.             function fmail(x){
  15.                 var pattern = /^\w{1,30}@{1}\w{1,15}\.{1}[a-z]{1,3}$/;
  16.                 if (!x.value.match(pattern)) {
  17.                     alert("Niepoprawny format adresu e-mail.");
  18.                     x.value = "";
  19.                 }
  20.  
  21.             }
  22.  
  23.             function freal(x){
  24.                 var pattern = /^[0-9]{1,2}\.{1}[0-9]{1,2}$/;
  25.                 if (!x.value.match(pattern)){
  26.                     alert("Niepoprawny format liczby rzeczywistej.");
  27.                     x.value = "";
  28.                 }
  29.                 else{
  30.                     if (x.value<10 || x.value>30){
  31.                         alert("Liczba musi miescic sie w przedziale od 10 do 30.");
  32.                         x.value = "";
  33.                     }
  34.                 }
  35.             }
  36.  
  37.             function fdayofweek(){
  38.                 var d = new Date();
  39.                 var currentDay = d.getDay();
  40.                 var x = document.getElementById("dow").value;
  41.                 if (x == currentDay) dow.disabled = true;
  42.                 else{
  43.                     var choice = confirm("Wybrany dzien rozni sie od dzisiejszego. Czy chcesz wprowadzić zmiany?");
  44.                     if (choice == true) dow.value = 0;
  45.                     else dow.disabled = true;
  46.                 }
  47.             }
  48.  
  49.             function fsubmit(){
  50.                 if (document.getElementById("x").checked == false){
  51.                     alert("Nie potwierdziles zgody na przetwarzanie danych osobowych.");
  52.                     document.getElementById("x").focus();
  53.                     return false;
  54.                 }
  55.                 if(document.code.value == ''){
  56.                     alert("Kod pocztowy jest wymagany.");
  57.                     return false;
  58.                 }
  59.                 else if(document.mail.value == ''){
  60.                     alert("Adres e-mail jest wymagany.");
  61.                     return false;
  62.                 }
  63.                 else if (document.real.value == ''){
  64.                     alert("Wartosć jest wymagana.");
  65.                     return false;
  66.                 }
  67.                 return true;
  68.             }
  69.         </script>
  70.     </head>
  71.     <body>
  72.         <form onsubmit="return fsubmit(this)" method="post">
  73.             Podaj kod pocztowy w formacie CC-CCC:
  74.             <input type="text" name="code" maxlength="6" onBlur="fcode(this)"/><br/><br/>
  75.             Podaj adres e-mail w formacie adres@dowolna.domena:
  76.             <input type="text" name="mail" maxlength="50" onBlur="fmail(this)"/><br/><br/>
  77.             Podaj dowolną liczbę rzeczywistą z przedziału od 10 do 30:
  78.             <input type="text" name="real" onBlur="freal(this)"/><br/><br/>
  79.             Wybierz dzień tygodnia:<br/>
  80.             <select id="dow" name="dayofweek" size="1" onchange="fdayofweek(this)">
  81.                 <option value="0" label=" "/>
  82.                 <option value="1"/>Poniedziałek
  83.                 <option value="2"/>Wtorek
  84.                 <option value="3"/>Środa
  85.                 <option value="4"/>Czwartek
  86.                 <option value="5"/>Piątek
  87.                 <option value="6"/>Sobota
  88.                 <option value="7"/>Niedziela
  89.             </select><br/><br/>
  90.             <input type="checkbox" id="x"/>
  91.             <label for="x">Wyrażam zgodę na przetwarzanie moich danych osobowych.</label><br/><br/>
  92.             <input type="submit"/>
  93.         </form>
  94.     </body>
  95. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement