Javascript submit() is not submitting the form

后端 未结 2 1304
小鲜肉
小鲜肉 2021-01-27 07:31

This is my code.

HTML

2条回答
  •  忘了有多久
    2021-01-27 07:42

    Several things

    1. Never use the reserved word "submit" in a form element's name or ID - it will hide the submit event handler from the JavaScript
    2. use the onsubmit to disable the button instead of using weird inline handlers. There is no href on a button for example
    3. You should not disable a button you need to click before clicking it

    Like this:

    
       
       
     
    

    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

提交回复
热议问题