Skip to content

Instantly share code, notes, and snippets.

@matijs matijs/postforms.js forked from adactio/postforms.js
Last active Aug 29, 2015

Embed
What would you like to do?
/*
Show a progress element for any form submission via POST.
Prevent the form element from being submitted twice.
*/
(function ( win, doc ) {
'use strict';
if ( !win.addEventListener ) {
// doesn't cut the mustard.
return;
}
var submitting = false;
function checkForm( event ) {
if ( submitting ) {
event.preventDefault();
}
else {
if ( event.target.method === 'post' ) {
submitting = true;
event.target.appendChild( doc.createElement('progress') );
}
}
}
doc.documentElement.addEventListener( 'submit', checkForm, false );
}( this, this.document ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.