<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]{6,}$/;
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 ="您的長度必須有6個字元長,必須包含一個數字和一個英文字母寬 "
notify.id = "notify";
var body = document.getElementById("body");
body.appendChild(notify);
</html>
}
}
};
</script>
沒有留言:
張貼留言