Advertisement
Guest User

Problem

a guest
May 31st, 2018
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 8.61 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3.     <head>
  4.         <meta charset="utf-8">
  5.         <title></title>
  6.     </head>
  7.     <body>
  8.         <form>
  9.              <input type="text" id="imie" placeholder="Wpisz imię"><label style="color:red;" id="lab01"></label><br/>
  10.             <input type="text" id="nazwisko" placeholder="Wpisz nazwisko"><label style="color:red;" id="lab02"></label><br/>
  11.             <input type="text" id="mail" placeholder="Wpisz mail"><label style="color:red;" id="lab1"></label><br/>
  12.             <input type="text" id="tel" placeholder="Wpisz telefon"><label style="color:red;" id="lab2"></label><br/>
  13.             <input type="text" id="pesel" placeholder="Wpisz pesel"><label style="color:red;" id="lab3"></label><br/>
  14.             <input type="text" id="haslo" placeholder="Wpisz haslo"><label style="color:red;" id="lab4"></label><br/>
  15.             <input type="text" id="miasto" placeholder="Wpisz miasto"><label style="color:red;" id="lab5"></label><br/>
  16.             <input type="text" id="ulica" placeholder="Wpisz ulicę"><label style="color:red;" id="lab6"></label><br/>
  17.             <input type="text" id="dom" placeholder="Wpisz nr domu"><label style="color:red;" id="lab7"></label><br/>
  18.             <input type="text" id="kod" placeholder="Wpisz kod pocztowy"><label style="color:red;" id="lab8"></label><br/>
  19.             <input type="button" value="Sprawdź" onclick="sprawdzaj()">
  20.         </form>
  21.         <div id="div1"></div>
  22.         <div id="div2"></div>
  23.        
  24.         <script>
  25.         function sprawdzaj()
  26.         {
  27.             var div1=document.getElementById("div1");
  28.             var imie=document.getElementById("imie").value;
  29.             var nazw=document.getElementById("nazwisko").value;
  30.             var email=document.getElementById("mail").value;
  31.             var tel=document.getElementById("tel").value;
  32.             var pesel=document.getElementById("pesel").value;
  33.             var haslo=document.getElementById("haslo").value;
  34.             var miasto=document.getElementById("miasto").value;
  35.             var ulica=document.getElementById("ulica").value;
  36.             var dom=document.getElementById("dom").value;
  37.             var kod=document.getElementById("kod").value;
  38.             var div2=document.getElementById("div2");
  39.             var lab01=document.getElementById("lab01");
  40.             var lab02=document.getElementById("lab02");
  41.             var lab1=document.getElementById("lab1");
  42.             var lab2=document.getElementById("lab2");
  43.             var lab3=document.getElementById("lab3");
  44.             var lab4=document.getElementById("lab4");
  45.             var lab5=document.getElementById("lab5");
  46.             var lab6=document.getElementById("lab6");
  47.             var lab7=document.getElementById("lab7");
  48.             var lab8=document.getElementById("lab8");
  49.             if(imie=="")
  50.                 {
  51.                     lab01.innerHTML="Pole jest puste";
  52.                     lab01.style="color:red";
  53.                 }
  54.            
  55.             //Nie działa
  56.             else if(imie.search('[0-9]')>1)
  57.                 {
  58.                     lab01.innerHTML="Imie zawiera niedozwolony znak";
  59.                     lab01.style="color:red";
  60.                 }
  61.             //
  62.            
  63.             else
  64.                 {
  65.                     lab01.innerHTML="Imie poprawne";
  66.                     lab01.style="color:green";
  67.                 }
  68.            
  69.             if(nazw=="")
  70.                 {
  71.                     lab02.innerHTML="Pole jest puste";
  72.                     lab02.style="color:red";
  73.                 }
  74.            
  75.             //Nie działa
  76.             else if(nazw.search('[0-9]')>1)
  77.                 {
  78.                     lab02.innerHTML="Nazwisko zawiera niedozwolony znak";
  79.                     lab02.style="color:red";
  80.                 }
  81.             //
  82.            
  83.             else
  84.                 {
  85.                     lab02.innerHTML="Nazwisko poprawne";
  86.                     lab02.style="color:green";
  87.                 }
  88.            
  89.             //Nie działa
  90.             if((imie!="")&&(imie.search('[0-9]')==0)&&(nazw!="")&&(nazw.search('[0-9]')==0))
  91.                {
  92.                    div1.innerHTML=("Witaj "+imie+" "+nazw);
  93.                 }
  94.             //
  95.            
  96.             var mail_wz=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  97.             if(email=="")
  98.                 {
  99.                     lab1.innerHTML="Pole jest puste";
  100.                     lab1.style="color:red";
  101.                 }
  102.            
  103.             //Nie działa
  104.             else if(mail_wz.test(email))
  105.                 {
  106.                     lab1.innerHTML=("Mail niepoprawny");
  107.                     lab1.style="color:red";
  108.                 }
  109.             else
  110.                 {
  111.                     lab1.innerHTML=("Mail poprawny");
  112.                     lab1.style="color:green";
  113.                 }
  114.             //
  115.            
  116.             if(tel=="")
  117.                 {
  118.                     lab2.innerHTML="Pole jest puste";
  119.                     lab2.style="color:red";
  120.                 }
  121.             else if((tel>=100000000)&&(tel<=999999999))
  122.                {
  123.                    lab2.innerHTML=("Telefon poprawny");
  124.                     lab2.style="color:red;";
  125.                    
  126.                 }
  127.             if(pesel=="")
  128.                 {
  129.                     lab3.innerHTML="Pole jest puste";
  130.                     lab3.style="color:red;";
  131.                 }
  132.             else if((pesel>=10000000000)&&(pesel<=99999999999))
  133.                {
  134.                    lab3.innerHTML="PESEL poprawny";
  135.                     lab3.style="color:green;";
  136.                 }
  137.             else
  138.                 {
  139.                     lab3.innerHTML=("PESEL niepoprawny");
  140.                     lab3.style="color:red;";
  141.                 }
  142.            
  143.             if(haslo=="")
  144.                 {
  145.                     lab4.innerHTML="Pole jest puste";
  146.                     lab4.style="color:red;";
  147.                 }
  148.            
  149.             //Nie działa
  150.             else if((haslo.length>=8)&&(haslo.search("[0-9]")>0))
  151.                {
  152.                    lab4.innerHTML=("Hasło silne");
  153.                     lab4.style="color:green";
  154.                 }
  155.             else
  156.                 {
  157.                     lab4.innerHTML=("Hasło za słabe!");
  158.                     lab4.style="color:red";
  159.                 }
  160.             //
  161.            
  162.             if(miasto=="")
  163.                 {
  164.                     lab5.innerHTML="Pole jest puste";
  165.                     lab5.style="color:red;";
  166.                 }
  167.             else if((miasto.length>=3)&&(miasto.search("[0-9]")<1))
  168.                {
  169.                    lab5.innerHTML=("Miasto poprawne");
  170.                     lab5.style="color:green;";
  171.                 }
  172.             else
  173.                 {
  174.                     lab5.innerHTML=("Miasto niepoprawne");
  175.                     lab5.style="color:red;";
  176.                 }
  177.            
  178.             if(ulica=="")
  179.                 {
  180.                     lab6.innerHTML="Pole jest puste";
  181.                     lab6.style="color:red;";
  182.                 }
  183.             else if((ulica.length>=3)&&(ulica.search("[0-9]")<1))
  184.                {
  185.                    lab6.innerHTML=("Ulica poprawna");
  186.                     lab6.style="color:green;";
  187.                 }
  188.             else
  189.                 {
  190.                     lab6.innerHTML=("Ulica niepoprawna");
  191.                     lab6.style="color:red;";
  192.                 }
  193.            
  194.             if(dom=="")
  195.                 {
  196.                     lab7.innerHTML="Pole jest puste";
  197.                     lab7.style="color:red;";
  198.                 }
  199.             else if(dom.length>=1)
  200.                 {
  201.                     lab7.innerHTML=("NR domu poprawny");
  202.                     lab7.style="color:green;";
  203.                 }
  204.             else
  205.                 {
  206.                     lab7.innerHTML=("NR domu niepoprawny");
  207.                     lab7.style="color:red;";
  208.                 }
  209.            
  210.             var kod_wz="/^\d\d-\d\d\d$/";
  211.             if(kod=="")
  212.                 {
  213.                     lab8.innerHTML="Pole jest puste";
  214.                     lab8.style="color:red;";
  215.                 }
  216.            
  217.             //Nie działa
  218.             else if(!kod_wz.test(kod))
  219.                 {
  220.                     lab8.innerHTML=("Kod pocztowy niepoprawny");
  221.                     lab8.style="color:red";
  222.                 }
  223.             else
  224.                 {
  225.                     lab8.innerHTML=("Kod pocztowy poprawny");
  226.                     lab8.style="color:green;";
  227.                 }
  228.             //
  229.         }
  230.         </script>
  231.     </body>
  232. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement