0

I am experiencing something very strange. When a form is submitted, I am disabling the submit button with the following code:

$(btn).addClass('sbmt_disable').attr('disabled', 'disabled'); 

However, the effect it creates is it appears to just reload the page, and the fields are empty. Is it not possible to submit a form, if the submit button is disabled then? If so, what is the alternative? The desired action is to prevent users from clicking on the form more than once.

5
  • 2
    Are you doing it onsubmit or onclick? Commented Mar 21, 2018 at 3:54
  • doing it onclick $('#contact_btn').click(function(e){.... Commented Mar 21, 2018 at 3:56
  • 2
    well there is your problem.... if you did it onsubmit of the form, you would not have issues.Disabling the button on click cancels the click. Commented Mar 21, 2018 at 3:56
  • no, that still didnt work, the form still doesnt submit $('#contact_form').submit(function(e){... Commented Mar 21, 2018 at 3:59
  • Than delay it with a timeout setTimeout(()=>{foo.disabled=true},1) or use pointer events in css to disable it. Commented Mar 21, 2018 at 3:59

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.