2013年11月11日 星期一

lab26


lab25



lab24












lab23









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}\))([-\/\.])\d{3}\1\d{4}/;
      function testInfo(phoneInput){
        var OK = re.exec(phoneInput.value);
        if (!OK)
            {
 window.alert(RegExp.input + " isn't a phone number with area code!");
            q.value="";
}
        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 action="#">
      <input id="phone" name="q"><button onclick="testInfo(document.getElementById('phone'));">Check</button>
    </form>
  </body>
</html>

2013年11月4日 星期一

lab22

<html>
<title>lab22</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>

 

       
function check(){
     var floatReg =/^([+-]?)[1-9]\d*(\.\d*)?,([+-]?)[1-9]\d*(\.\d*)?$/;
         if(!floatReg.test(f.q.value)){
         
                alert("It's not a correct format");
            f.q.value="";
            document.f.q.focus();
            return false;
       
         }
}

</script>                      
</html>

lab21


lab20

lab19