标签

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 = /^(?=.*\w)(?=.*\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 = "Password need to be least 6  characters long and consist of upprcase characters, lowercase characters,and digits only.";
         
            notify.id = "notify";

var body = document.getElementById("body");
body.appendChild(notify);
}
}
};
    </script>
</html>

没有评论:

发表评论