<html>
  <head>
    <title>My JSP 'exam.jsp' starting page</title>
<script type="javascript" > function login(){
if (document.form1.number.value.length==0)  {  
alert("请输入您姓名!");
document.form1.number.focus();
return  false;
}
if(document.form1.password.value.length ==0)  {  
alert("请输入您姓名!");
document.form1.password.focus();
return  false;
}
}
 
 </script>  </head>
  
  <body>
  <div align="center" >
   <form name="form1"   method="post"   action="testLogin1.jsp">
   准考证号:<input type="text" name="number"/><br>
   考生密码:<input type="text" name="password" /><br>
   学生<input type="radio" value=0 name="identity"  checked="checked"/>
   管理员<input type="radio" value=1 name="identity"  /><br>
   <input type="submit" value="登录"  onClick="return login();" />
<input type="reset"  value="清空" />
  
   </form>
    </div> <br>
  </body>
</html>郁闷了 看了半天没看出来 
老提示缺少对象
谁帮我看看,谢了。

解决方案 »

  1.   

    <script type="text/javascript">  或者干脆就别写type。
      

  2.   

    这就跟http通信协议有关了。
    文本类型有:text/html,text/css,text/javascript,text/xml..................等。
    图片类型有:image/png,image/gif.....................等。具体可网上查查。其实<script>.............</script>  这样也就行了。现在的浏览器都认识那是js语言的声明块了。