http://blog.sina.com.cn/itubuntu[订阅]
字体大小: 正文
jsp经验---onclick( )(2008-07-16 10:08:38)

<%@ page language="java" contentType="text/html; charset=gbk"
    pageEncoding="gbk"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>软件学院通讯录</title>
<script type="text/javascript">
   function validate()
   
       if(document.form.username.value=="")
       {
           alert("请输入姓名!");
           document.form.username.focus();
           return false;
       }
       if(document.form.birth.value=="")
       {
           alert("请输入出生年月!");
           document.form.birth.focus();
           return false;
       }
      
       var format=/(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/;
      
       if(!format.test(document.form.birth.value))
       {
           alert("请按以下格式输入出生年月:03/03/2009");
           return false;
       }

       var numRow=document.form.checkbox.length;
       var h=0;
       for(var i=0;i<numRow;i++)
       {
            if(form.checkbox[i].checked)
                   h++;
       }
       if(h==0)
       {
          alert("请选择兴趣爱好!");
          return false;
       }
      
       if(document.form.text.value=="")
       {
           alert("请输入备注内容!");
           document.form1.text.focus();
           return false;
       }
      
      
       form.action="Login";
       from.submit();
   }
   function selectAll()
   {
       var numRow=document.form.checkbox.length;
     
       if(document.form.selectall.checked)
       {
          for(var i=0;i<numRow;i++)
              document.form.checkbox[i].checked=true;
       }
       else
       {
          for(var i=0;i<numRow;i++)
               document.form.checkbox[i].checked=false;
       }
   }
</script>
</head>
<body>
<form id="form" name="form1" method="post" action="">
  <table width="586" height="427" border="1">
    <tr>
      <td colspan="4"  align="center">软件学院通讯录</td>
    </tr>
    <tr>
      <td width="46">姓名:</td>
      <td width="182"><input type="text" name="username" /></td>
      <td width="67">性别:</td>
      <td width="263"><label>
        <input name="radiobutton" type="radio" value="radiobutton" checked="checked" />
      男       
      <input type="radio" name="radiobutton" value="radiobutton" />
      女</label></td>
    </tr>
    <tr>
      <td>出生年月:</td>
      <td><label>
        <input type="text" name="birth" />
      </label></td>
      <td>学历:</td>
      <td><label>
        <select name="select">
          <option selected="selected">中专</option>
          <option >大专</option>
          <option>本科</option>
          <option>研究生</option>
          <option>博士</option>
        </select>
      </label></td>
    </tr>
    <tr>
      <td height="62">兴趣爱好:</td>
      <td colspan="3">
      <label>
       <input type="checkbox" name="checkbox" value="checkbox"  onClick="alert('旅游');"/>
      旅游
      <input type="checkbox" name="checkbox" value="checkbox" />
      听音乐
      <input type="checkbox" name="checkbox" value="checkbox" />
      上网
      <input type="checkbox" name="checkbox" value="checkbox" />
      篮球
      <input type="checkbox" name="checkbox" value="checkbox" />
      摄影
      <input type="checkbox" name="checkbox" value="checkbox" />
      舞蹈
      <input type="checkbox" name="checkbox" value="checkbox" />
      文学
      <input type="checkbox" name="checkbox" value="checkbox" />
      爬山
      <input type="checkbox" name="checkbox" value="checkbox" />
      气功</label></td>
      <td><input type="checkbox" name="selectall" value="checkbox" onClick="selectAll()"/>(全选)</td>
    </tr>
    <tr>
      <td>备注:</td>
      <td colspan="3"><label>
        <textarea name="text" cols="70" rows="10"></textarea>
      </label></td>
    </tr>
    <tr>
      <td colspan="4" align="center">考试成绩</td>
    </tr>
    <tr>
      <td rowspan="5">考试成绩</td>
      <td>考试科目</td>
      <td>考试时间</td>
      <td>成绩</td>
    </tr>
    <tr>
      <td>Java基础</td>
      <td>2006.10.2</td>
      <td>67</td>
    </tr>
    <tr>
      <td>数据库</td>
      <td>2006.11.2</td>
      <td>75</td>
    </tr>
    <tr>
      <td>Java高级</td>
      <td>2006.12.2</td>
      <td>80</td>
    </tr>
    <tr>
      <td>UML</td>
      <td>2007.2.3</td>
      <td>70</td>
    </tr>
  </table>
  <p>
    <label></label>
    <label>
     <div align="center">
       <input type="button" name="Submit" value="提交" onClick="validate()"/>
      </div>
    </label>
  </p>
</form>
</body>

  • 评论加载中,请稍候...
发评论    明星私家相册

验证码:看不清楚数字吗?点击这里再试试。收听验证码

发评论

以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

相关博文
读取中...
推荐博文
读取中...