Skip to content Skip to sidebar Skip to footer

Javascript Submit() Is Not Submitting The Form

This is my code. HTML
  • use the onsubmit to disable the button instead of using weird inline handlers. There is no href on a button for example
  • You should not disable a button you need to click before clicking it
  • Like this:

    <formid="add_new_video"method="post"class="appnitro"style="margin-left:70px;"action="<?phpecho base_url()?>videos/save"><inputtype="text"name="name"><buttontype="submit"id="buttonSub"class="dark_text_link">Add New Video</button></form>

    using

    window.onload=function() {
      document.getElementById("add_new_video").onsubmit=function() {
        document.getElementById('buttonSub').disabled = true;
        setTimeout(function(){document.getElementById('buttonSub').disabled = false;},1000);
      }        
    }
    

    You do not actually need to ENABLE the form button again since you submit to the same page. The button will be enabled when the page reloads - this is of course not true if you target the form elsewhere

    Solution 2:

    Replace button with this tag element.

    <inputtype="submit"class="dark_text_link" disabled id="btnsubmit" href="javascript:void(0);" onclick="return addVideo();"/>
    

    Post a Comment for "Javascript Submit() Is Not Submitting The Form"