如果是submit按钮就用 onsubmit事件  button的话可以用 onclick()

解决方案 »

  1.   

    form中的input控件是一起提交的,怎么可能有的提交有的不提交<html>
    <head>
    <title>前端设备基本参数设置</title><script type="text/javascript">    function testpost(){
                var fobj=document.getElementsByTagName("input");
                for (var i=0;i<fobj.length ; i++)
                {
            if(fobj[i].type=="text")
            if(fobj[i].value == null || fobj[i].value == "")
    {
                     return;
    }
                }
                document.getElementsByName("form_set")[0].submit();       }</script></head>
    <body>
    <h1>前端设备基本参数设置</h1><p></p>测试URL:SetPuBasicInfo<p></p>
    <form name="form_set" id="form_set" method="get" action="SetPuBasicInfo">
    <table border="2">
    <tr>
    <td>puId</td>
    <td><input type="text" name="puId"></td>
    <td>string(32)</td>
    <td>PU的标识</td>
    </tr>
    <tr>
    <td>puName</td>
    <td><input type="text" name="puName"></td>
    <td>string(32)</td>
    <td>PU的名称</td>
    </tr>
    <tr>
    <td>puPassword</td>
    <td><input type="text" name="puPassword"></td>
    <td>string(32)</td>
    <td>PU的设备密码</td>
    </tr>
    </table>
    <input type="button"  onclick="testpost()">
    </form>
    </body>
    </html>
      

  2.   

    你用的<input type="submit">提交按钮 事件是onsubmit (在form 表单里用 onsubmit=“testpost('form_set')”)
      

  3.   

    <html>
    <head>
    <title>前端设备基本参数设置</title><script type="text/javascript">    function testpost(name)
        {

    var isTrue = "false";
           
    var fobj=document.getElementById(name);     for (var i=0; i< fobj.length ; i++)
            {
       
       alert(fobj.elements[i].value);   
       
       if( fobj.elements[i].value == "")
       {
                 
          isTrue = "true";
       }

           } if ( isTrue == "false" ) 
    {
              alert("ok");
      fobj.action = "2.htm";  
      alert(fobj.action);
    }
    else
    {
              alert("该项不能提交");
    }   }</script></head>
    <body>
    <h1>前端设备基本参数设置</h1><p></p>测试URL:SetPuBasicInfo<p></p>
    <form name="form_set" id="form_set" >
    <table border="2">
    <tr>
    <td>puId</td>
    <td><input type="text" name="puId"></td>
    <td>string(32)</td>
    <td>PU的标识</td>
    </tr>
    <tr>
    <td>puName</td>
    <td><input type="text" name="puName"></td>
    <td>string(32)</td>
    <td>PU的名称</td>
    </tr>
    <tr>
    <td>puPassword</td>
    <td><input type="text" name="puPassword"></td>
    <td>string(32)</td>
    <td>PU的设备密码</td>
    </tr>
    </table>
    <input type="submit" id="btn" value="提交" onclick="testpost('form_set')">
    </form>
    </body>
    </html>
    你看看吧,这样是可以的
      

  4.   

    lihui_shine(浪尖赏花) 说的对!form中的input控件是一起提交的,怎么可能有的提交有的不提交。但是你可以在action="SetPuBasicInfo" action指向的页面中对传递过来的参数判断那个参数是空的
      

  5.   

    如果form中的input控件是一起提交的,那能不能用javascript去提交呢?
      

  6.   

    你的form对象.submit();我在3楼用过的