<br>姓名: <input type="text" name="aaaa" size="12">   你的name怎么都取关键字呀,换一下leaMsgBoard.name.value  这样的都换成下面的
document.getElementsByName("laaaa")[0].value

解决方案 »

  1.   

    <script language="JavaScript"> 
    <style type="text/css"> 
    body { 
    margin-left: 0px; 
    margin-top: 0px; 
    margin-right: 0px; 
    margin-bottom: 0px; 
    background="../src/back.gif"; 
      } 
    </style> 
    //这里不要写在<script></script>里function formCheck() 

    if(leaMsgBoard.name.value==""){ 
    alert("请输入你的姓名!"); 
    leaMsgBoard.name.focus(); 
    return false; 

    if(leaMsgBoard.class.value==""){ //class是保留字.
    alert("请输入你的班级!"); 
    leaMsgBoard.class.focus(); 
    return false; 
    } if(leaMsgBoard.contact.value==""){ 
    alert("请填入你的电子邮件!"); 
    leaMsgBoard.contact.focus(); 
    return false; 


    </script> <form action="setMsg.jsp" method="post" name="leaMsgBoard" onsubmit="return formCheck()" > 
    <table width="700" border="0" align="center" cellpadding="4" 1" bgcolor="#ebcellspacing="ebeb"> 
    <tr> 
    <td> 
      <br>姓名: <input type="text" name="name" size="12"> 
      <p>班级: <input type="text" name="class" size="12"> </p> 
      <P>联系方式: <input type="text" name="contact" size="20"> </p> 
      <input type="submit" name="SubmitBtn" value="确认"> 
    </td> </tr> </table> 
    </form>
      

  2.   

    leaMsgBoard.name.value 换成  document.leaMsgBorad.name.value  试下
      

  3.   

    5楼啊。我把class改了但是还是没用啊。。
      

  4.   

    看这个http://www.codefan.net/cached/web/q/20080602/598216232008060209260833659821623.shtml?codefanid=80389
      

  5.   

    很简单的问题啊,你把元素的name属性都定义成拼音缩写:
    html:
    <form action="setMsg.jsp" method="post" name="leaMsgBoard" onsubmit="return formCheck()" > 
    <table width="700" border="0" align="center" cellpadding="4" 1" bgcolor="#ebcellspacing="ebeb"> 
    <tr> 
    <td> 
      <br>姓名: <input type="text" name="mc" size="12"> 
      <p>班级: <input type="text" name="bj" size="12"> </p> 
      <P>联系方式: <input type="text" name="lxfs" size="20"> </p> 
      <input type="submit" name="SubmitBtn" value="确认"> 
    </td> </tr> </table> 
    </form>
    js:
    function formCheck() 

    if(leaMsgBoard.mc.value==""){ 
    alert("请输入你的姓名!"); 
    leaMsgBoard.mc.focus(); 
    return false; 

    if(leaMsgBoard.bj.value==""){ 
    alert("请输入你的班级!"); 
    leaMsgBoard.bj.focus(); 
    return false; 
    } if(leaMsgBoard.lxfs.value==""){ 
    alert("请填入你的电子邮件!"); 
    leaMsgBoard.lxfs.focus(); 
    return false; 


      

  6.   

    把css移到script外面  然后把input 的name="name" 和 name="class" 改成不是关键字就Ok 了
      

  7.   

    可我改了都没用啊
    改后的全部代码:
    <%@ page language="java" import="java.sql.*" contentType="text/html; charset=gb2312"%>  
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
     <link href="msgStyle.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background="../src/back.gif";
       }
    </style>
    <script language="JavaScript">
    function formCheck()
    {
     if(leaMsgBoard.names.value==""){
    alert("请输入你的姓名!");
    leaMsgBoard.name.focus();
    return false;
    }
     if(leaMsgBoard.classes.value==""){
    alert("请输入你的班级!");
    leaMsgBoard.classes.focus();
    return false;
    }
     if(leaMsgBoard.content.value==""){
    alert("留言不能为空!");
    leaMsgBoard.content.focus();
    return false;
    }
     if(leaMsgBoard.contact.value==""){
    alert("请填入你的电子邮件!");
    leaMsgBoard.contact.focus();
    return false;
    }
     if (leaMsgBoard.GetCode.value=="")
    {
    alert("请填写验证码。");
    leaMsgBoard.GetCode.focus();
    return false;
    }
    return true;
    }
    //......省略部分
    </script>
    </head><body>
    <%-- Begin of the form --%>
    <form action="setMsg.jsp" method="post" name="leaMsgBoard"  onSubmit="return formCheck()">
    <table width="700" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#ebebeb">
    <tr> 
    <td class="pt9">
       <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;姓名:&nbsp;  <input type="text" name="names" size="12" />
       <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;班级:&nbsp; <input type="text" name="classes" size="12" /></p>
       <P>&nbsp;&nbsp;联系方式:&nbsp; <input type="text" name="contact" size="20" /></p><table width="100%" border="0" cellpadding="0" cellspacing="0" class="pt9">
    <tr>
    <td width="50" valign="top">留言:</td>
    <td>
    <table width="98%">
    <tr><td><textarea name="Message" id="content" rows=10 cols=98%></textarea> </td></tr>
    </table>
    </td>
    </tr>
    </table><table width="100%" border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td width="62%">*请输入右侧的验证码:
          <input name="GetCode" type="text" id="GetCode" size="4" maxlength="4" />  <img src="../src/editor/GetCode.bmp" width="72" height="18" id="GetCodeImg" /></td>
        <td width="38%">
          <input name="replyer" type="hidden" value="" />
          <input name="reply_content_id" type="hidden" value="" />
          <input name="userid" type="hidden" value="48327" />
          <input type="hidden" name="sum_upload_file_size" value="0" />
          <input type="hidden" name="upload_files" value="" />
          <input type="hidden" name="upload_file_count" value="0" />
          <input type="submit" name="SubmitBtn" id="SubmitBtn" value="确认留言"  />
          <input type="reset" name="Reset" value="取  消"/>
    </td>
      </tr>
    </table>
    </td>
    </tr></table>
    </form>
    <!-- End of the Form -->
    <!-- begin of the list of Messages --> 
    //......省略部分
    <!-- End of the list of Messages --> <!-- End -->   </body>
    </html>
      

  8.   

    <script language="JavaScript"> 
    function formCheck() 

    if(leaMsgBoard.names.value==""){ 
    alert("请输入你的姓名!"); 
    leaMsgBoard.name.focus(); 
    return false; 

    //......其它不变
     leaMsgBoard.submit();
    </script> 
    把<form action="setMsg.jsp" method="post" name="leaMsgBoard"  onSubmit="return formCheck()"> 
    中的onSubmit="return formCheck()"去掉,改为
    <form action="setMsg.jsp" method="post" name="leaMsgBoard">
    放在JS里面提交;
      

  9.   

    if(leaMsgBoard.names.value==""){ 
    alert("请输入你的姓名!"); 
    leaMsgBoard.name.focus(); 
    return false; 

    这里出错了,变量名没改彻底.应改为: leaMsgBoard.names.focus(); 
    在JS中任何一个小错误都会导致后面的JS代码不被执行(在不调试状态下又没有提示).
      

  10.   

    1、把submit改回button,把submit()写到button的onclick里面去,不然就直接走action了
    2、你写的leaMsgBoard.name.value好像取不到,老老实实用id取把
      

  11.   

    <style type="text/css"> 
    body { 
    margin-left: 0px; 
    margin-top: 0px; 
    margin-right: 0px; 
    margin-bottom: 0px; 
    background="../src/back.gif"; 
      } 
    </style> 
    <script language="JavaScript"> 
    function formCheck() 

    alert()
    if(leaMsgBoard.oname.value==""){ 
    alert("请输入你的姓名!"); 
    leaMsgBoard.oname.focus(); 
    return false; 

    if(leaMsgBoard.oclass.value==""){ 
    alert("请输入你的班级!"); 
    leaMsgBoard.oclass.focus(); 
    return false; 
    } if(leaMsgBoard.contact.value==""){ 
    alert("请填入你的电子邮件!"); 
    leaMsgBoard.contact.focus(); 
    return false; 


    </script> <form action="setMsg.jsp" method="post" name="leaMsgBoard" onsubmit="return formCheck();" > 
    <table width="700" border="0" align="center" cellpadding="4" 1" bgcolor="#ebcellspacing="ebeb"> 
    <tr> 
    <td> 
      <br>姓名: <input type="text" name="oname" size="12"> 
      <p>班级: <input type="text" name="oclass" size="12"> </p> 
      <P>联系方式: <input type="text" name="contact" size="20"> </p> 
      <input type="submit" name="SubmitBtn" value="确认"> 
    </td> </tr> </table> 
    </form>很简单的问题 把你的<style>拿到<script>标签外面即可 还有别以关键字命名
      

  12.   

    各位我终于找到错误的地方了。错的是我没有贴上来的这段代码(在<script language="JavaScript">与</script>之间还有个函数):function showimage()
    {document.images.faceimg.src=face_image[parseInt(document.leaMsgBoard.face.options[document.leaMsgBoard.face.selectedIndex].value)];
    }
    face_image=new Array(16);
    face_image[0]=../src/headpics/m01.gif";
    face_image[1]=../src/headpics/m02.gif";
    face_image[2]=../src/headpics/m03.gif";
    face_image[3]=../src/headpics/m04.gif";
    face_image[4]=../src/headpics/m05.gif";
    face_image[5]=../src/headpics/m06.gif";
    face_image[6]=../src/headpics/m07.gif";
    face_image[7]=../src/headpics/m08.gif";
    face_image[8]=../src/headpics/m09.gif";
    face_image[9]=../src/headpics/m10.gif";
    face_image[10]=../src/headpics/m11.gif";
    face_image[11]=../src/headpics/m12.gif";
    face_image[12]=../src/headpics/m13.gif";
    face_image[13]=../src/headpics/m14.gif";
    face_image[14]=../src/headpics/m15.gif";
    face_image[15]=../src/headpics/m16.gif";在form表单中与之对应的是:
    <td width="120" rowspan="3" align="center" valign="top"><br>
    选择头像<br>
    <br>
    <SELECT size=1 name="face" onchange=showimage()>
    <option value="0" selected>好开心</option>
    <option value="1">好难过</option>
    <option value="2">好伤心</option>
    <option value="3">要唱歌</option>
    <option value="4">正哭泣</option>
    <option value="5">很满意</option>
    <option value="6">很惊喜</option>
    <option value="7">好生气</option>
    <option value="8">好害怕</option>
    <option value="9">真倒霉</option>
    <option value="10">扁着嘴</option>
    <option value="11">平常心</option>
    <option value="12">冒冷汗</option>
    <option value="13">伤脑筋</option>
    <option value="14">笑死了</option>
    <option value="15">好气愤</option>
    </SELECT>
    <br>
    <br>
    <br>
    <img src="../src/headpics/m01.gif" name="faceimg" id="faceimg" /></td>请问该怎样改啊??
      

  13.   

    face_image=new Array(16); 
    face_image[0]=../src/headpics/m01.gif"; 
    face_image[1]=../src/headpics/m02.gif"; 
    face_image[2]=../src/headpics/m03.gif"; 
    face_image[3]=../src/headpics/m04.gif"; 
    face_image[4]=../src/headpics/m05.gif"; 
    face_image[5]=../src/headpics/m06.gif"; 
    face_image[6]=../src/headpics/m07.gif"; 
    face_image[7]=../src/headpics/m08.gif"; 
    face_image[8]=../src/headpics/m09.gif"; 
    face_image[9]=../src/headpics/m10.gif"; 
    face_image[10]=../src/headpics/m11.gif"; 
    face_image[11]=../src/headpics/m12.gif"; 
    face_image[12]=../src/headpics/m13.gif"; 
    face_image[13]=../src/headpics/m14.gif"; 
    face_image[14]=../src/headpics/m15.gif"; 
    face_image[15]=../src/headpics/m16.gif"; 看到双引号没有匹配到了吗?