Lab8
密碼按錯,下面出現didn't match
密碼按對
程式碼
<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() {
//R
var passwordRegex = /^[\D]+[\w_]+[A-Za-z\d]{4,}$/;
if(!passwordRegex.test(document.getElementById("examplePass").value)){
console.log("Regex didn't match");
var notify = document.getElementById("notify");
if(notify === null) {
notify = document.createElement("p");
notify.textContent = "Passwords need to at least 6位元 第一位元須為數任意字母 第二須為符號 "
notify.id = "notify";
var body = document.getElementById("body");
body.appendChild(notify);
}
}
};
</script>
</html>
沒有留言:
張貼留言