How to disable submit button once it has been clicked?

后端 未结 18 1556
轻奢々
轻奢々 2020-12-01 05:06

I have a submit button at the end of the form.

I have added the following condition to the submit button:

onClick=\"this.disabled=true;
this.value=\'         


        
18条回答
  •  醉酒成梦
    2020-12-01 05:19

    Your question is confusing and you really should post some code, but this should work:

    onClick="this.disabled=true; this.value='Sending...'; submitForm(); return false;"
    

    I think that when you use this.form.submit() it's doing what happens naturally when you click the submit button. If you want same-page submit, you should look into using AJAX in the submitForm() method (above).

    Also, returning false at the end of the onClick attribute value suppresses the default event from firing (in this case submitting the form).

提交回复
热议问题