提交以后检测名为 theform 的 form 里所有的元素,如果类型是 submit 或者 reset 就禁止不过这么写很没效率

解决方案 »

  1.   

    在提交按钮里加一个 onclick="this.disabled=true"例如 <input type="submit" value="提交" onclick="this.disabled = true">reset 按钮给禁止根本一点用都没有,表单已经开始提交了再怎么按 reset 压根没影响了
      

  2.   

    不能在submit提交的时候就disabled,因为提交以后还要判断是否有内容,有内容才disabled。
      

  3.   

    指定表单的onsubmit事件的处理onSubmit="return mySubmit();"当返回假(false)时不会提交
    在自定义的mySubmit()里做提交前的判断
      

  4.   

    这样怎么加入submit.disabled呢?
      

  5.   

    function submitonce(theform)
    {
        if (document.all||document.getElementById)
        {
            for (i=0;i<theform.length;i++)
            {
            var tempobj=theform.elements[i]
            if(tempobj.type.toLowerCase() =="submit"||tempobj.type.toLowerCase()=="reset")
            tempobj.disabled=true
            }
        }
    }
    <form method="post" name="theform" onsubmit="return submitonce(theform)">