Problem/Motivation

Currently when WET-BOEW inline form validation is enabled for a webform with multiple pages, the Previous button on the webform triggers the validation. This means in order to go back a page, the user must complete all of the required fields on the current page, which is not ideal. Users should be able to go back a page without triggering validation.

Steps to reproduce

On a paged webform, add a required field to the second page. Then when filling out the webform, go to the second page, leave the required field blank, and click the Previous button. You will see wet-boew validation kicking in.

Comments

smulvih2 created an issue. See original summary.

smulvih2’s picture

Status: Active » Needs review
StatusFileSize
new2.52 KB

We needed to disable WET-BOEW inline client-side validation when users click the Previous button on multi-step Drupal Webforms. Users should be able to move back without being blocked by validation errors.

Approaches Tested

1. HTML5 formnovalidate attribute
Added via hook_webform_submission_form_alter().
Result: Browser validation disabled, but WET/jQuery Validate still executed, so errors continued to appear.

2. jQuery Validate .cancel class trick
Added class="cancel" to the Previous button.
Result: Works in plain jQuery Validate, but WET wraps validation and ignores this path, so validation still triggered.

3. Using global once() to intercept click
JS attempted to intercept click and re-submit.
JS correctly attached, but validation still fired before the handler, indicating event order problem.

Final Solution

The issue was order of execution. WET’s validation submit handlers were firing before our script. The successful approach was to:

  • Mark the Previous button in PHP: data-wet-skip-validation="1"
  • In JS:
    • Use capture-phase event listener (addEventListener(..., true))
    • Call preventDefault() and stop propagation
    • Submit the form via native form.submit(), bypassing WET/jQuery handlers

Result:
Previous button now navigates back a page with no inline validation, while Next / Submit continue to enforce WET validation normally.

smulvih2’s picture

Status: Needs review » Fixed

Included in 6.1.x.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.