-
Notifications
You must be signed in to change notification settings - Fork 0
/
example5.html
82 lines (66 loc) · 2.66 KB
/
example5.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!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);
oPwCheck.watch('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, "<") + "</pre>");
</script>
<hr>
DOCS: <a href="http://www.axel-hahn.de/docs/ahpwcheck/index.htm" target="_blank">http://www.axel-hahn.de/docs/ahpwcheck/index.htm</a>
</body>
</html>