From 30c8b48996c3e898fdeaad48cb5ff1c8c9431272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20H=C3=A4usler?= Date: Sat, 6 Dec 2014 21:39:59 +0100 Subject: [PATCH] prevent forms from being double-submitted --- public/js/forms.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/public/js/forms.js b/public/js/forms.js index 630d8c25..a8c7f6ce 100644 --- a/public/js/forms.js +++ b/public/js/forms.js @@ -1,8 +1,8 @@ function check_all(id) { var obj = document.getElementById(id); var boxes = obj.getElementsByTagName("input"); - for(var i = 0; i < boxes.length; i++) { - if(boxes[i].type == "checkbox" && !boxes[i].disabled) + for ( var i = 0; i < boxes.length; i++) { + if (boxes[i].type == "checkbox" && !boxes[i].disabled) boxes[i].checked = true; } } @@ -10,8 +10,15 @@ function check_all(id) { function uncheck_all(id) { var obj = document.getElementById(id); var boxes = obj.getElementsByTagName("input"); - for(var i = 0; i < boxes.length; i++) { - if(boxes[i].type == "checkbox") + for ( var i = 0; i < boxes.length; i++) { + if (boxes[i].type == "checkbox") boxes[i].checked = false; } } + +$(function() { + $('form').submit(function(ev) { + $('input[type="submit"]').prop("readonly", true).addClass("disabled"); + return true; + }); +});