2013年10月7日 星期一
LAB 8
<html>
<head>
</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 = /^(?=.*\d)(?=.*\W).{6,}$/;
if(!passwordRegex.test(document.getElementById("examplePass").value)){
console.log("Regex did'ny match");
var notify = document.getElementById("notify");
if (notify === null){
notify = document.createElement("p");
notify.textContent = "Passwords need to be upon 6 characters long and consist of uppercase characters, lowercase characters, and gigits only."
notify.id = "notify";
var body = document.getElementById("body");
body.appendChild(notify);
}
}
};
</script>
</html>
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言