File: example5.html

Recommend this page to a friend!
  Classes of Axel Hahn   AH JavaScript Password Strength Check   example5.html   Download  
File: example5.html
Role: Example script
Content type: text/plain
Description: Example script
Class: AH JavaScript Password Strength Check
Calculate and display the strength of a password
Author: By
Last change: Update of example5.html
Date: 2 years ago
Size: 2,721 bytes


Class file image Download
<!DOCTYPE html> <html> <head> <title>Demo 5 for password checker</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="ahpwcheck.class.min.js"></script> <link rel="stylesheet" type="text/css" href="example.css" /> <style> form div{background: #f8f8f8; margin: 1em 0; padding: 1em;} #outscore{background: #fc3;} </style> </head> <body> <h1>Demo 5 for password checker (ahpwcheck.class.js)</h1> <nav> <a href="example.html">example 1</a> <a href="example2.html">example 2</a> <a href="example3.html">example 3</a> <a href="example4.html">example 4</a> <a href="example5.html" class="active">example 5</a> </nav> <!-- ************************************************************** --> <h2>Callback</h2> <p class="info"> You can react if the user types something in the password field: use the callback.<br> Here is a demo to show and update the score. </p> <form> enter password: <input type="password" id="ePassword"> <div> Score: <span id="outscore">-</span> </div> </form> <div id="outpwcheck"></div> <script id="source"> var aOptions = { 'callback': 'mycallback()' }; /** * custom callback function */ function mycallback(){ var sPassword=document.getElementById('ePassword').value; document.getElementById('outscore').innerHTML=oPwCheck.getScore(sPassword); } var oPwCheck = new ahpwcheck(aOptions);'ePassword', 'outpwcheck'); </script> <!-- ************************************************************** --> <h2>Explaination</h2> <p> Use the key "callback" in the aOptions array and use it while initializing the object.<br> I defined a custom function mycallback that fills the dom id "outscore". <br> </p> <script> document.write("<pre>" + document.getElementById("source").innerHTML.replace(/</g, "&lt;") + "</pre>"); </script> <hr> DOCS: <a href="" target="_blank"></a> </body> </html>