2014年3月17日 星期一

lab13

<html> <head> </head> <body id="body"> <form action="javascript:void(0);" id="exampleForm"> <input id="examplePass" type="text" /> <input type="submit" /> </form> <script> document.getElementById("exampleForm").onsubmit = function(){ var passwordRegex =/^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))*$/; 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 = "請輸入正確的網址"; notify.id ="notify"; var body =document.getElementById("exampleForm"); body.appendChild(notify); } } }; </script>

lab12

<html> <title>lab12</title> <body> <form action="http://maps.google.com/maps" method="get" name="f" onsubmit="return check()"> <input name="q" type="text" /><br /> <input name="send" type="submit" value="search" /> </form> </body> <script> document.getElementById("exampleForm").onsubmit =function() { var passwordRegex = /^[-|+]*[\d]*[.|\d][\d]*[,][-|+]*[\d]*[.|\d][\d]*$/; 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 = "error" notify.id = "notify"; var body = document.getElementById("body"); body.appendChild(notify); } } }; </script> </html>lab12

lab11


lab10


2014年3月10日 星期一

lab8

<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]{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>

lab9


lab7