Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function estCodePIN()
- {
- codePIN = document.getElementById("codePIN").value
- if (codePIN.length == 4)
- {
- compteur = 0;
- for (indice = 0; indice < 5; indice++)
- {
- if (estChiffre(codePIN[indice]) == true)
- {
- compteur = compteur + 1;
- }
- }
- if (compteur == 4)
- {
- document.getElementById("estCodePIN").value = true;
- }
- else
- {
- document.getElementById("estCodePIN").value = false;
- }
- }
- }
- function estChiffre()
- {
- if (codePIN.length == 1)
- {
- for (indice = 0; indice < 10; indice++)
- {
- if (parseInt(codePIN) = indice)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
- <section>
- <h3>Le formulaire :</h3>
- <div>Code PIN : <input type="text" label="codePIN" id="codePIN"></div>
- <div>Bon / Faux : <input type="text" label="estCodePIN" id="codePIN"></div>
- <div><button onclick="estCodePIN()">Tester</button></div>
- </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement