Skip to content

Instantly share code, notes, and snippets.

@jonathandavis
Created June 5, 2014 17:56
Show Gist options
  • Save jonathandavis/b30be29d78481c7471b7 to your computer and use it in GitHub Desktop.
Save jonathandavis/b30be29d78481c7471b7 to your computer and use it in GitHub Desktop.
$.fn.extend({
disableSubmit: function () {
return $(this).data('label',$(this).val()).attr('disabled',true).addClass('disabled').val($co.submitting);
},
enableSubmit: function (){
return $(this).attr('disabled', false).removeClass('disabled').val($(this).data('label'));
}
});
// Validate paycard number before submit
checkoutForm.on('shopp_validate',function () {
var submitButtons = checkoutButtons.find('input').disableSubmit();
if (!validcard()) checkoutForm.data('error', ["Not a valid card number.",billCard.get(0)]);
if ( checkoutForm.data('error').length > 0 ) submitButtons.enableSubmit();
}).on('submit', function (e) {
e.preventDefault();
setTimeout(function () { checkoutForm.unbind('submit').submit(); }, 1); // Give time for the button style to change
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment