最新回應

Loading...

2014年3月10日 星期一

notepad++ code (lab7)

<html>
<head>
</head>
<body id="body">
<from action="javascript:void(0);" id="exampleform">
<input type="password"  id="examplepassword" />
<input type="submit" />
</form>
</body>
<script>
document.getElementById("exampleForm").onsubmit = function(){
var passwordregex = /^[A-Za-z\d]{6,}$/;

if(!passwordregex.test(document.getElementById("examplepass").value))
{
var notify = document.getElementById("notify");
if (notify==null){
notify = document.createElement("p");
notify.textcontent = "passwords,need to be least 6 characters long
 and consist of uppercase characters , lowercase
 characters , and digits only."
notify.id = "notify";
var body = document.getElementById("body");
body.appendChild(notify);
}
}
};

</script>

</html>

test 2 :

<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 = /^[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="passwords,need to be least 6 characters long and consist of uppercase characters , lowercase  characters , and digits only."

 notify.id = "notify";
 var body = document.getElementById("exampleform");
 body.appendChild(notify);
}
}
};

</script>


correct :
<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 = /^[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="Passwords need to be between 6 and 8 characters long and consist of uppercase characters, lowercase caracters, and digits only."
notify.id = "notify";
var body = document.getElementById("exampleform");
body.appendChild(notify);
}
}
};
</script>
</html>