Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         function estCodePIN()
  2.         {
  3.             codePIN = document.getElementById("codePIN").value
  4.             if (codePIN.length == 4)
  5.             {
  6.                 compteur = 0;
  7.                 for (indice = 0; indice < 5; indice++)
  8.                 {
  9.                     if (estChiffre(codePIN[indice]) == true)
  10.                         {
  11.                             compteur = compteur + 1;
  12.                         }
  13.                 }
  14.                
  15.                 if (compteur == 4)
  16.                 {
  17.                     document.getElementById("estCodePIN").value = true;
  18.                 }
  19.                 else
  20.                 {
  21.                     document.getElementById("estCodePIN").value = false;
  22.                 }
  23.                
  24.                    
  25.             }
  26.         }
  27.        
  28.         function estChiffre()
  29.         {
  30.             if (codePIN.length == 1)
  31.             {
  32.                 for (indice = 0; indice < 10; indice++)
  33.                 {
  34.                     if (parseInt(codePIN) = indice)
  35.                         {
  36.                             return true;
  37.                         }
  38.                     else
  39.                         {
  40.                             return false;
  41.                         }
  42.                 }
  43.             }
  44.            
  45.         }
  46.  
  47.  
  48.     <section>
  49.         <h3>Le formulaire :</h3>
  50.         <div>Code PIN : <input type="text" label="codePIN" id="codePIN"></div>
  51.         <div>Bon / Faux : <input type="text" label="estCodePIN" id="codePIN"></div>
  52.         <div><button onclick="estCodePIN()">Tester</button></div>
  53.     </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement