我想在提交表单的时候对表单数据进行检查,请问怎么样访问表单数据

解决方案 »

  1.   

    document.getElementById("controlId").value
      

  2.   

    <form name="f" action="b.jsp">
      <table>
        <tr>
           <td>
              <input type="text" name="username">
            </td>
        </tr>
        <tr>
           <td>
              <input type="button" name="validator" onclick="vali()">
            </td>
        </tr>
      </table>
    </from>
    <script>
      function vali()
      {
        var v=document.f.username.value;
        if(v=="")
           {
              alert(“please input value!”);
            }
        else 
          document.f.action();
      }
    </script>