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
<html>
	<head>	
		<title>PasswordChecker</title>
	</head>
	<body id="body">
		<form action="javascript:void(0);" id ="exampleForm">
			<input type="password" id="examplePass"/>
			<input type="submit"/>
		</form>
	</body>
	<script>
		document.getElementById("exampleForm").onsubmit = function() {
			var passwordRegex = /[a-zA-Z0-9]{6,}/;
			
			var str = document.getElementById("examplePass").value;
			if(!passwordRegex.test(str)){
				console.log("Regex didn't match");
				var notify = document.getElementById("notify");
				if (notify === null){
					notify = document.createElement("p");
					notify.textContent = "Passwords need to be longer than 6 characters and consist of punctuation characters and digits.";
					notify.id = "notify";
					
					var body = document.getElementById("body");
					body.appendChild(notify);
				}
			}
		};
	</script>
</html>