怎么实现超级连接提交表单且验证提交的内容

解决方案 »

  1.   


    formObj.submit();示例:
    <form id="form1">
    ....
    </form><a href="javascript:;" onclick="document.getElementById('form1').submit()">提交表单</a>
      

  2.   

    这样?
    <script type="text/javascript">
    <!--
    function kkk(){
    var obj = document.getElementById('form1');
    if (obj.kk.value==""){
    alert("kk为空");
    return ;
    }
    obj.submit();
    }//-->
    </script>
    <body>
    <form method="post" action="" name="form1" id="form1">
    <input type="text" name="kk">
    <a href="#" onclick="kkk()">提交</a>
    </form>
    </body>
      

  3.   

    <script type="text/javascript">
    function submitvialink() {
     //客户端验证表单的代码
     //假设checkFlag变量保存验证结果是否通过
     if (checkFlag) document.form.submit();
     else return false;
    }
    </script>
    <a href="javascript:submitvialink();">submit</a>
      

  4.   


    <form name="frm" method="get" action="news/WriteData.asp">
      <tr>
        <td width="90px"><input type="text" id="time" name="time"></td>
        <td width="80px"><!--#include file="news/area.asp"--></td>
        <td width="160px"><!--#include file="news/customer.asp"--></td>
        <td width="350px"><textarea rows="5" id="content" name="content"></textarea></td>
        <td width="90px"><select><option>数据绑定</option></select></td>
        <td width="90px"><a href="#" onclick="ok()">添加</a>
    </td>
      </tr>
      </form>
    function ok()
    {
    if(document.getElementById("time").value=="")
    {
    alert("请输入时间!");
    return ;
    }
    if(document.getElementById("province").value=="0")
    {
    alert("请选择省");
    return ;
    }
    if(document.getElementById("types").value=="0")
    {
    alert("请选择客户类型");
    return ;
    }
    if(document.getElementById("txtSearch").value=="")
    {
    alert("请输入客户名");
    return ;
    }
    if(document.getElementById("content").value=="")
    {
    alert("请填写工作内容");
    return ;
    }
    document.frm.submit();
    }我现在是希望把ok这一部分分成2个函数,即一个验证函数,一个提交函数,假如验证函数是这样的
    function checkForm()
    {
    if(document.getElementById("time").value=="")
    {
    alert("请输入时间!");
    return false;
    }
    if(document.getElementById("province").value=="0")
    {
    alert("请选择省");
    return false;
    }
    if(document.getElementById("types").value=="0")
    {
    alert("请选择客户类型");
    return false;
    }
    if(document.getElementById("txtSearch").value=="")
    {
    alert("请输入客户名");
    return false;
    }
    if(document.getElementById("content").value=="")
    {
    alert("请填写工作内容");
    return false;
    }
    }
    那么那个ok()函数怎么写?