Darksoul__

Untitled

Jan 5th, 2021 (edited)
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta charset="utf-8">
  5.         <title>Registrazione</title>
  6.         <link rel="stylesheet" type="text/css" href="stile.css?version=51">
  7.     </head>
  8.     <body>
  9.         <form class='box' name='mioForm' action='signupdatabase.php' method='POST' onsubmit='return controllo();'>
  10.             <h1>Iscriviti</h1>
  11.             <input type='text' name='user' placeholder='Username'>
  12.             <input type='text' name='email' placeholder='Email'>
  13.             <input type='password' name='pass' placeholder='Password'>
  14.             <input type='password' name='rip_pass' placeholder='Ripeti la password'>
  15.             <input type='submit' name='ok' value='Iscriviti'>            
  16.             <a href='index.php'>Sei già iscritto? Accedi!</a>
  17.         </form>
  18.         <script type="text/javascript">
  19.             function controllo(){  
  20.                 user=document.forms["mioForm"]["user"];
  21.                 email=document.forms["mioForm"]["email"];
  22.                 pass=document.forms["mioForm"]["pass"];
  23.                 rip_pass=document.forms["mioForm"]["rip_pass"];
  24.  
  25.                 user_valido=controllaUser(user);
  26.  
  27.                 email_valida=controllaEmail(email);
  28.                
  29.                 pass_uguali=controllaPassword(pass);
  30.  
  31.                 form_valido=pass_uguali&&user_valido&&email_valida;
  32.                 return form_valido;
  33.             }
  34.  
  35.             function controllaUser(user){
  36.                 controllo=true;
  37.                 string=user.value;
  38.                 if(string!=""){
  39.                     if(string.charAt(0).toUpperCase()==string.charAt(0).toLowerCase()||string.length()<5)
  40.                         controllo=false;
  41.                     else
  42.                         controllo=false;
  43.                 }
  44.                 else
  45.                     controllo=false;
  46.  
  47.                 if(!controllo)
  48.                     user.style.borderColor="red";
  49.                 else
  50.                     user.style.borderColor="#3498db";
  51.  
  52.                 return controllo;
  53.             }
  54.  
  55.             function controllaPassword(pass){
  56.                 controllo=true;
  57.                 controllaCampoVuoto(pass);
  58.                 controllaCampoVuoto(rip_pass);
  59.                 if(rip_pass.value!=pass.value){  
  60.                     pass.style.borderColor="red";
  61.                     rip_pass.style.borderColor="red";
  62.                 }
  63.                 else{
  64.                     pass.style.borderColor="red";
  65.                     rip_pass.style.borderColor="red";
  66.                 }
  67.                 return controllo;
  68.             }
  69.  
  70.             function controllaEmail(email){
  71.                 controllo=true;
  72.                 if(controllaCampoVuoto(email))
  73.                     if(emailValida(email.value))
  74.                         controllo=false;
  75.                 else
  76.                     controllo=false;
  77.  
  78.                 if(!controllo)
  79.                     email.style.borderColor="red";
  80.                 else
  81.                     email.style.borderColor="#3498db";
  82.  
  83.                 return controllo;
  84.             }
  85.  
  86.             function controllaCampoVuoto(campo){
  87.                 corretto=true;
  88.                 if(campo.value=="")
  89.                     campo.style.borderColor="red";
  90.                 else{
  91.                     campo.style.borderColor="#3498db";
  92.                     corretto=false;
  93.                 }
  94.                 return corretto;
  95.             }
  96.            
  97.             function emailValida(email) {
  98.                 const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  99.                 return re.test(email);
  100.             }
  101.         </script>
  102.     </body>
  103. </html>
Add Comment
Please, Sign In to add comment