Skip to content

Commit

Permalink
disable button while submitting to prevent multi-submission (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras authored Oct 8, 2022
1 parent 05f1c5c commit 9cde8f2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion public/viewtopic.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@
$defaultMessage = ($permissions >= Permissions::Registered) ? "" : "** Your account appears to be locked. Did you confirm your email? **";
$inputEnabled = ($permissions >= Permissions::Registered) ? "" : "disabled";

echo <<<EOF
<script>
function disableRepost() {
var btn = $('#postBtn');
btn.attr('disabled', true);
btn.html('Sending...');
}
</script>
EOF;
echo "<form action='/request/forum-topic-comment/create.php' method='post'>";
echo csrf_field();
echo "<input type='hidden' name='topic' value='$thisTopicID'>";
Expand All @@ -298,7 +307,7 @@ class="w-full mb-2"
EOF;
echo "<div class='flex justify-between mb-2'>";
echo "<span class='textarea-counter' data-textarea-id='commentTextarea'></span>";
echo "<button class='btn' $inputEnabled>Submit</button>"; // TBD: replace with image version
echo "<button id='postBtn' class='btn' onclick='this.form.submit(); disableRepost()' $inputEnabled>Submit</button>"; // TBD: replace with image version
echo "</div>";
echo "</form>";

Expand Down

0 comments on commit 9cde8f2

Please sign in to comment.