/
index2.php
39 lines (37 loc) · 1.31 KB
/
index2.php
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form>
Login: <input type="text" name="login" id="login"><br>
Password: <input type="password" name="password" id="password"><br>
<input type="button" value="Ga maar versturen" id="knop" onclick=checkValue()>
</form>
<script>
function checkValue() {
let aantal = 0
let inputs = document.getElementsByTagName('input');
for (let index = 0; index < inputs.length; ++index) {
if(inputs[index].id == "login") {
aantal = 3
} else if(inputs[index].id == "password") {
aantal = 6
}
if(inputs[index].id == "knop") {
inputs[index].style.backgroundColor = "white"
} else {
if(inputs[index].value.length < aantal) {
inputs[index].style.backgroundColor = "orange"
} else if(inputs[index].value.length >= aantal) {
inputs[index].style.backgroundColor = "lightgreen"
}
}
}
}
</script>
</body>
</html>