Skip to content

Require every "check to submit" checkbox before enabling submit - #104

Merged
corsacca merged 2 commits into
masterfrom
fix-multiple-check-to-submit
Oct 8, 2026
Merged

corsacca merged 2 commits into
masterfrom
fix-multiple-check-to-submit

Conversation

@corsacca

@corsacca corsacca commented Oct 8, 2026

Copy link
Copy Markdown
Member

Reported on the forum: https://community.disciple.tools/topic/183/multiple-check-to-submit-checkboxes-the-form-can-be-submitted-when-only-one-is-checked

Problem

When a form has two or more checkbox fields set to "Require checkbox checked", checking any one of them enables the submit button. Someone can submit without checking all of the required boxes, which matters for consent checkboxes (GDPR, age, etc.).

Cause

In public/public.js the click handler on .input-checkbox set the button's disabled state from only the checkbox that was clicked: prop('disabled', !jQuery(this).prop('checked')). It never looked at the other required checkboxes.

There was also a smaller timing issue: enforce_requires_check_to_submit() disabled the button whenever any required checkbox existed, whether or not it was checked. If a user checked the box during the 5-second anti-bot countdown, the button stayed disabled once the countdown finished until they unchecked and re-checked it. Checking a box during the countdown could also enable the button early.

Fix

  • enforce_requires_check_to_submit() now checks every check_to_submit checkbox and enables the button only when all of them are checked.
  • It does nothing until the countdown is complete. When the countdown finishes, it runs once to set the button's final state.
  • The checkbox handler listens to change and calls the same function.

Forms with no required checkboxes behave as before: submit is enabled when the countdown ends.

Testing

I tested in headless Chromium with a page that had two required checkboxes and one optional checkbox:

  • Checking one required box during the countdown: the button stays disabled.
  • After the countdown, with only one required box checked: still disabled.
  • Checking the optional box: still disabled.
  • Checking both required boxes: enabled.
  • Unchecking one of them: disabled again.

Note: the submit button is still only a client-side check. Nothing on the server validates required checkboxes. That is unchanged by this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GjYTexmHbnYghvDQuLhfLW


Generated by Claude Code

claude added 2 commits October 8, 2026 16:10
The click handler only looked at the checkbox that was clicked, so with
two or more required checkboxes, checking any one enabled the submit
button. Evaluate all required checkboxes together, and wait for the
anti-bot countdown to finish before enabling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GjYTexmHbnYghvDQuLhfLW
… works

Composer 2.10 now fails 'composer install' when composer.lock predates
allow-plugins and composer.json doesn't declare it. Declare the plugin
and refresh the lock hash (package versions unchanged).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GjYTexmHbnYghvDQuLhfLW

corsacca commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

CI note: both PHP jobs on c9b6b6f failed at composer install, before any test ran. The runner's Composer 2.10.3 now rejects the old composer.lock because composer.json doesn't define allow-plugins.

This isn't caused by this PR's change, which only touches public/public.js. composer.json and composer.lock are the same on master, so master would fail the same way.

The fix is in #105. I've ported the same commit here as 2ea9337 so this PR can go green. Once #105 merges, that commit will have nothing left to change here.


Generated by Claude Code

@corsacca
corsacca merged commit 72ad083 into master Oct 8, 2026
4 checks passed
@corsacca
corsacca deleted the fix-multiple-check-to-submit branch October 8, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants