jQuery: Prevent Double Form Submission CodeUnit 25 APR 2009

Coffee CupA very clever little jQuery function here that I’ve gone and lifted from some deep, dark domain of the Web.

Essentially what it does is prevent accidental double form submission (which could for example happen if it appears to the user that nothing is happening after he already pressed on the submit button once), by assigning a function to the submit action of each and every form on a particular page. The function simply disables any image or submit buttons that are bound to that form, thereby preventing a secondary click in one foul swoop.

var $that = $(this);
$that.find("input[type='image'],input[type='submit']").attr("disabled", "true");});

Like I said, pretty clever.

Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.

  • T.madhava kumar

    If it is really works for my forms, i will appreciate you a hundred times for deep searching ……. the dark web

  • No problem, glad I could help! :)