2013年11月11日 星期一

LAB 26



LAB 25



LAB 24






LAB 23









Homework 11-5-2013

<!DOCTYPE html>
<html> 
  <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
    <meta http-equiv="Content-Script-Type" content="text/javascript"> 
    <script type="text/javascript"> 
      var re = /\(?\d{3}\)?([-\/\.])\d{3}\1\d{4}/; 
      function check(){ 
    var OK = re.exec(f.q.value);
        if (!OK) 
          {window.alert(RegExp.input + " isn't a phone number with area code!");
         f.q.value="";
        document.f.q.focus();
        return false; }    
         else
       window.alert("Thanks, your phone number is " + OK[0]); 
       
 }
    </script> 
  </head> 
  <body> 
    <p>Enter your phone number (with area code) and then click "Check".
        <br>The expected format is like ###-###-####.</p>
    <form name="f" action="#" onsubmit="return check()" method="get"> 
       check:<input type="text" name="q">     
     <input id="phone" type="submit" value="check">
    </form> 
  </body> 
</html>


號碼錯誤將提示,光標移回。。


正確則提示為正確號碼:


2013年11月4日 星期一

LAB22

<html>

<form name="f" action="http://maps.google.com/maps" onsubmit="return check()" method="get">
google map:<input type="text" name="q">
<input name="send" type="submit" value="go go google">
</form>
<script>
var floatReg =/^(-?\d+)(\.\d+)?[,](-?\d+)(\.\d+)?$/;
function check()
{ if(!floatReg.test(f.q.value)){
alert("it's not correct format");
 f.q.value="";
 document.f.q.focus();
 return false;
}
 
}
</script>
</html>


LAB 21

LAB 20



LAB 19