Wikipedia

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>
</body>
 <script>


document.getElementById("exampleForm").onsubmit =function() {
  var passwordRegex = /^[\d]*[.]*[\d]*[.]*[\d]*[.]*[\d]|*\w{1,}*[.]*\w{1,}*[.]*\w{1,}*[.]*(\w{1,})$/;

  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 = "not 正確的。"
   notify.id = "notify";
 
   var body = document.getElementById("body");
   body.appendChild(notify);
   }
  }
 };

  </script>
</html>



沒有留言:

張貼留言