5 Replies - 544 Views - Last Post: 14 July 2013 - 01:45 PM Rate Topic: -----

#1 adn258  Icon User is offline

  • D.I.C Addict

Reputation: 11
  • View blog
  • Posts: 762
  • Joined: 31-August 11

Preventing Multiple Accidental User Submits Is This Ok?

Posted 09 July 2013 - 02:45 PM

So having nothing to do with deliberate posts sometimes users and people that don't understand that you click a button once will try to submit something twice. I was thinking this simple Javascript will prevent most of that problem look below.


<button type="button" onclick="this.disabled = true; this.form.submit();">Register Account</button>



This submits the form that it is in, and disables the button. Is there any slowness or disadvantage to using this vs just

<button type="submit"</button>



Where the button itself submits instead of using an unclick event for the form submission? If you use a button like this though disabling the button after it is clicked becomes more complicated!!

Is This A Good Question/Topic? 0
  • +

Replies To: Preventing Multiple Accidental User Submits Is This Ok?

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,261
  • Joined: 08-June 10

Re: Preventing Multiple Accidental User Submits Is This Ok?

Posted 09 July 2013 - 10:11 PM

two questions:
- what if the user reloads the page?
- what if Java­Script is disabled?
Was This Post Helpful? 0
  • +
  • -

#3 Anthonidas  Icon User is offline

  • D.I.C Head

Reputation: 30
  • View blog
  • Posts: 218
  • Joined: 25-April 11

Re: Preventing Multiple Accidental User Submits Is This Ok?

Posted 10 July 2013 - 12:38 AM

you should add at least a <noscript>-tag or catch if someone has JS disabled and inform him how to proceed...
Was This Post Helpful? 0
  • +
  • -

#4 adn258  Icon User is offline

  • D.I.C Addict

Reputation: 11
  • View blog
  • Posts: 762
  • Joined: 31-August 11

Re: Preventing Multiple Accidental User Submits Is This Ok?

Posted 13 July 2013 - 03:59 PM

View PostDormilich, on 09 July 2013 - 10:11 PM, said:

two questions:
- what if the user reloads the page?
- what if Java­Script is disabled?


If javascript is disabled you should use a noscript argument as the user below suggests and tell them to only click it once. I have server side PHP code that blocks multiple submissions using a form key too. I don't understand what a page reload has to do with this? If someone reloads the page so what friend? I'm not understand why that would be bad or how that's relevant?
Was This Post Helpful? 0
  • +
  • -

#5 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,261
  • Joined: 08-June 10

Re: Preventing Multiple Accidental User Submits Is This Ok?

Posted 13 July 2013 - 04:54 PM

Quote

I don't understand what a page reload has to do with this?

a page reload after a form submit can trigger the form submit again (though most browsers alert the user about that).
Was This Post Helpful? 0
  • +
  • -

#6 adn258  Icon User is offline

  • D.I.C Addict

Reputation: 11
  • View blog
  • Posts: 762
  • Joined: 31-August 11

Re: Preventing Multiple Accidental User Submits Is This Ok?

Posted 14 July 2013 - 01:45 PM

View PostDormilich, on 13 July 2013 - 04:54 PM, said:

Quote

I don't understand what a page reload has to do with this?

a page reload after a form submit can trigger the form submit again (though most browsers alert the user about that).


I just tried that on my forms it didn't work. That's what I have a token and security question for on forms to keep this from happening when someone is trying to do something deliberately. The point of disabling the button is to just keep people that don't know what they are doing from accidentally submitting twice (most of the time).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1