Index: lams_central/web/comments/edit.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/comments/edit.jsp,v diff -u -r1.3 -r1.4 --- lams_central/web/comments/edit.jsp 18 Jan 2016 02:18:33 -0000 1.3 +++ lams_central/web/comments/edit.jsp 20 Apr 2016 03:31:54 -0000 1.4 @@ -29,6 +29,13 @@ function editCommentSubmit() { + var btnName = "editCommentSubmitButton"; + if ( isDisabled(btnName) ) { + return false; + } + + disableButton(btnName); + var theForm = $(editForm); if ( validateBodyText($('#editFormBody').val(), <%=CommentConstants.MAX_BODY_LENGTH%>, "") ) { @@ -48,6 +55,9 @@ reloadThread(response,'','',''); }); } // end validateBodyText + else { + enableButton(btnName); + } return false; }; @@ -68,7 +78,7 @@   - + Index: lams_central/web/comments/new.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/comments/new.jsp,v diff -u -r1.5 -r1.6 --- lams_central/web/comments/new.jsp 18 Jan 2016 02:18:33 -0000 1.5 +++ lams_central/web/comments/new.jsp 20 Apr 2016 03:31:54 -0000 1.6 @@ -12,9 +12,16 @@ }); }); + var btnName = "newCommentSubmitButton"; + function newCommentSubmit() { + + if ( isDisabled(btnName) ) { + return false; + } var theForm = $(newForm); + disableButton(btnName); if ( validateBodyText($('#newFormBody').val(), <%=CommentConstants.MAX_BODY_LENGTH%>, "") ) { @@ -47,12 +54,16 @@ clearNewForm(); } else if ( response.errMessage ) { alert(response.errMessage); + enableButton(btnName); } else { alert(''); } }); } // end validateBodyText + else { + enableButton(btnName); + } return false; } @@ -76,7 +87,7 @@   - + Index: lams_central/web/comments/reply.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/comments/reply.jsp,v diff -u -r1.3 -r1.4 --- lams_central/web/comments/reply.jsp 18 Jan 2016 02:18:33 -0000 1.3 +++ lams_central/web/comments/reply.jsp 20 Apr 2016 03:31:54 -0000 1.4 @@ -26,6 +26,14 @@ }); function replyFormSubmit() { + + var btnName = "replyCommentSubmitButton"; + if ( isDisabled(btnName) ) { + return false; + } + + disableButton(btnName); + var theForm = $(replyForm); if ( validateBodyText($('#replyFormBody').val(), <%=CommentConstants.MAX_BODY_LENGTH%>, "") ) { @@ -47,7 +55,10 @@ reloadThread(response,'','',''); }); } // end validateBodyText - return false; + else { + enableButton(btnName); + } + return false; } function cancelReply() { @@ -67,7 +78,7 @@   - + Index: lams_central/web/includes/javascript/comments.js =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/comments.js,v diff -u -r1.4 -r1.5 --- lams_central/web/includes/javascript/comments.js 18 Jan 2016 02:18:33 -0000 1.4 +++ lams_central/web/includes/javascript/comments.js 20 Apr 2016 03:31:54 -0000 1.5 @@ -42,3 +42,17 @@ alert(errorCannotRedisplayMessage); } } + + /** Disable the submit button when pressed to stop double submission. disabled = true doesn't stop the link working it just + * greys it out. So we need to test with isDisabled() in the submit methods too! Messy. */ + function disableButton(buttonId) { + $("#"+buttonId).attr("disabled", true); + $("#"+buttonId).addClass("disabled"); + } + function isDisabled(buttonId) { + return $("#"+buttonId).attr("disabled"); + } + function enableButton(buttonId) { + $("#"+buttonId).removeAttr("disabled"); + $("#"+buttonId).removeClass("disabled"); + }