-
Notifications
You must be signed in to change notification settings - Fork 11
disable button to prevent double submit #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,16 +156,29 @@ | |
> | ||
"; | ||
if ($SQL->accDeletionRequestExists($USER->uid)) { | ||
echo "<input type='submit' value='Request PI Account' disabled />"; | ||
echo " | ||
<input | ||
type='submit' value='Request PI Account' disabled | ||
onclick='this.form.submit(); this.disabled=true;' | ||
/> | ||
"; | ||
echo " | ||
<label style='margin-left: 10px'> | ||
You cannot request PI Account while you have requested account deletion. | ||
</label> | ||
"; | ||
} else { | ||
if ($SQL->requestExists($USER->uid)) { | ||
$prompt = "onclick='return confirm(\"Are you sure you want to cancel this request?\")"; | ||
echo "<input type='submit' value='Cancel PI Account Request' $prompt'/>"; | ||
echo " | ||
<input | ||
type='submit' value='Cancel PI Account Request' | ||
onclick=' | ||
confirm(\"Are you sure you want to cancel this request?\") | ||
&& this.form.submit() | ||
&& this.disabled=true; | ||
' | ||
/> | ||
"; | ||
echo " | ||
<label style='margin-left: 10px'> | ||
Your request has been submitted and is currently pending | ||
|
@@ -174,8 +187,16 @@ | |
"; | ||
} else { | ||
echo "<input type='hidden' name='form_type' value='pi_request'/>"; | ||
$prompt = "onclick='return confirm(\"Are you sure you want to request a PI account?\")"; | ||
echo "<input type='submit' value='Request PI Account' $prompt'/>"; | ||
echo " | ||
<input | ||
type='submit' value='Request PI Account' | ||
onclick=' | ||
confirm(\"Are you sure you want to request a PI account?\") | ||
&& this.form.submit() | ||
&& this.disabled=true; | ||
' | ||
/> | ||
"; | ||
} | ||
} | ||
echo "</form>"; | ||
|
@@ -199,7 +220,10 @@ | |
> | ||
<input type='hidden' name='delIndex' value='$i' /> | ||
<input type='hidden' name='form_type' value='delKey' /> | ||
<input type='submit' value='×' /> | ||
<input | ||
type='submit' value='×' | ||
onclick='this.form.submit(); this.disabled=true;' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling form.submit() in onclick bypasses onsubmit and HTML5 validation, and because the handler doesn't return false, the native submit runs too—risking double-submit. Change to: onclick='this.disabled = true; return true;' (also apply to 'Set Login Shell' at lines 250–255 and 'Request Account Deletion' at lines 288–291). Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
/> | ||
</form> | ||
</div>"; | ||
} | ||
|
@@ -216,12 +240,16 @@ | |
echo "<option>$shell</option>"; | ||
} | ||
echo " | ||
</select> | ||
<br> | ||
<input id='submitLoginShell' type='submit' value='Set Login Shell' /> | ||
</form> | ||
<hr> | ||
<h5>Account Deletion</h5> | ||
</select> | ||
<br> | ||
<input | ||
type='submit' | ||
id='submitLoginShell' value='Set Login Shell' | ||
onclick='this.form.submit(); this.disabled=true;' | ||
/> | ||
</form> | ||
<hr> | ||
<h5>Account Deletion</h5> | ||
"; | ||
|
||
if ($hasGroups) { | ||
|
@@ -237,13 +265,23 @@ | |
<input type='hidden' name='form_type' value='account_deletion_request' /> | ||
"; | ||
if ($SQL->accDeletionRequestExists($USER->uid)) { | ||
echo "<input type='submit' value='Request Account Deletion' disabled />"; | ||
echo " | ||
<label style='margin-left: 10px'> | ||
Your request has been submitted and is currently pending</label> | ||
<input | ||
type='submit' value='Request Account Deletion' | ||
onclick='this.form.submit(); this.disabled=true;' | ||
disabled | ||
/> | ||
<label style='margin-left: 10px'> | ||
Your request has been submitted and is currently pending | ||
</label> | ||
"; | ||
} else { | ||
echo "<input type='submit' value='Request Account Deletion' />"; | ||
echo " | ||
<input | ||
type='submit' value='Request Account Deletion' | ||
onclick='this.form.submit(); this.disabled=true;' | ||
> | ||
"; | ||
} | ||
echo "</form>"; | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -95,7 +95,10 @@ | |||||
echo "<form action='' method='POST' id='cancelPI'> | ||||||
<input type='hidden' name='pi' value='{$requested_account->gid}'> | ||||||
<input type='hidden' name='form_type' value='cancelPIForm'> | ||||||
<input name='cancel' style='margin-top: 10px;' type='submit' value='Cancel Request'/> | ||||||
<input | ||||||
name='cancel' style='margin-top: 10px;' type='submit' value='Cancel Request' | ||||||
onclick='this.form.submit(); this.disabled=true;' | ||||||
/> | ||||||
</form>"; | ||||||
echo "</td>"; | ||||||
echo "</tr>"; | ||||||
|
@@ -144,7 +147,7 @@ | |||||
onsubmit='return confirm(\"Are you sure you want to leave the PI group " . $group->gid . "?\")'> | ||||||
<input type='hidden' name='form_type' value='removePIForm'> | ||||||
<input type='hidden' name='pi' value='" . $group->gid . "'> | ||||||
<input type='submit' value='Leave Group'> | ||||||
<input type='submit' value='Leave Group' onclick='this.form.submit(); this.disabled=true;'> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling this.form.submit() in onclick bypasses the form's onsubmit handler at line 150 (the confirmation) and HTML5 validation, and the handler doesn't prevent the default, so the browser will also perform the native submit—risking double-submit. Remove the programmatic submit and let the form submit naturally after disabling: onclick='this.disabled = true; return true;'
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
</form> | ||||||
</td>"; | ||||||
echo "</tr>"; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,7 +13,7 @@ | |||||
<input type="text" id="pi_search" name="pi" placeholder="Search PI by NetID" required> | ||||||
<div class="searchWrapper" style="display: none;"></div> | ||||||
</div> | ||||||
<input type="submit" value="Send Request"> | ||||||
<input type="submit" value="Send Request" onclick="this.form.submit(); this.disabled=true;"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this.form.submit() bypasses onsubmit handlers and constraint validation, and because the handler doesn't return false, the default submit also runs—potential double-submit. Use: onclick='this.disabled = true; return true;'
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
</form> | ||||||
|
||||||
<script> | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -103,7 +103,10 @@ | |||||
<p>You may need to remind them.</p> | ||||||
<hr> | ||||||
<form action="" method="POST"> | ||||||
<input name="cancel" style='margin-top: 10px;' type='submit' value='Cancel Request'/> | ||||||
<input | ||||||
name="cancel" style='margin-top: 10px;' type='submit' value='Cancel Request' | ||||||
onclick='this.form.submit(); this.disabled=true;' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Programmatic submit inside onclick bypasses onsubmit/HTML5 validation and, since the handler does not return false, the native submit also occurs—potential double-submit. Prefer: onclick='this.disabled = true; return true;' (same applies to the Request Account button at lines 158–163).
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
/> | ||||||
</form> | ||||||
<?php endforeach; ?> | ||||||
<?php else : ?> | ||||||
|
@@ -149,7 +152,10 @@ | |||||
</a>. | ||||||
</label> | ||||||
<br> | ||||||
<input style='margin-top: 10px;' type='submit' value='Request Account'> | ||||||
<input | ||||||
style='margin-top: 10px;' type='submit' value='Request Account' | ||||||
onclick='this.form.submit(); this.disabled=true;' | ||||||
/> | ||||||
</form> | ||||||
<?php endif; ?> | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Programmatic submit bypasses onsubmit/validation and the handler doesn't prevent the default, so the native submit also occurs—risking double-submit. Use: onclick='this.disabled = true; return true;'
Copilot uses AI. Check for mistakes.