An HTML form is set to invalid when it is submitted (or when validation is explicitly requested) and at least one submittable, non-disabled candidate control in it fails its constraint validation: the form's checkValidity() returns false, submit events are blocked by constraint validation, and the browser refuses to submit the form—though it's "set to invalid" only in the ordinary sense that the form's validity check fails, since HTML has no separate stored "invalid" flag on the form itself. The precise trigger matters: novalidate on the form, formnovalidate on a submit button, disabled controls, or controls that are barred from constraint validation can leave a visibly wrong field in the form while the form still validates.
The Core Mechanism: Constraint Validation, Not a Form-Level Flag
The HTML specification defines constraint validation on individual form controls. A form is not a passive object that "is invalid"; it is a collection of candidate controls, and the form is invalid for submission purposes when any candidate fails.
The key pieces:
Candidate for constraint validation. A form control participates in validation unless it is barred from constraint validation. Barred controls include disabled controls, controls with readonly (for the applicable types), input type="hidden", input type="reset", and input type="button", plus button type="button" and button type="reset". Also, elements inside a datalist are barred. Crucially, a barred control's constraints are never checked, so a required hidden input does not block submission. Submittable elements. Validation applies to submittable controls (button, input, select, textarea, and formerly object/keygen in older specs). Only controls associated with the form are candidates; a control can be associated via the form attribute even if it sits outside the element in the DOM. The form's validity. The form is a "form owner" aggregating its candidates. form.checkValidity() returns false if any candidate is invalid, and it fires invalid events on failing controls. form.reportValidity() does the same but also shows the browser's constraint validation UI (typically a tooltip or bubble).
So "when is the form set to invalid?" The answer is: when a validation check runs across the form's candidates and finds at least one failing constraint—most commonly during a submit attempt.
The Common Trigger: Form Submission
The dominant real-world trigger is submission. When the user activates a submit button and no novalidate/formnovalidate is in effect, the browser performs interactive validation:
1: It gathers the form's candidate controls. 2: For each, it evaluates constraints: required, type (e.g., email, url, number, date), pattern, min/max/step on numeric and date types, minlength/maxlength/maxlength (and minlength where supported for text-like inputs), plus setCustomValidity(). 3: If any candidate is invalid, the invalid event fires on each failing control (these bubble in modern browsers, but note that invalid is not cancelable), the submit is blocked, and—if the user initiated it—the browser shows the first failing control's message.
Important nuance: the submit event never fires when interactive validation blocks submission. A listener on submit will not run for a form blocked by validation. This is different from the invalid event, which does fire.
checkValidity() and reportValidity() as Explicit Triggers
Beyond submission, you can force a validity evaluation:
form.checkValidity() returns a boolean and fires invalid events, but shows no UI. form.reportValidity() returns a boolean, fires invalid events, and shows the browser's UI.
Calling either on a form evaluates the aggregate. This is how a script "sets" the form's validation state at a chosen moment, for example before enabling a "Next" button. There is no property like form.invalid that is automatically kept up to date; you must call one of these methods or inspect individual controls.
Each control also has validity (a ValidityState object of booleans: valueMissing, typeMismatch, patternMismatch, tooShort, tooLong, rangeUnderflow, rangeOverflow, stepMismatch, badInput, customError, and the aggregate valid), plus validationMessage and willValidate. The form itself does not expose a validity property; only controls and (in the spec, historically) the form's aggregate methods do.
What Does Not Make the Form Invalid
Several conditions look like they should block submission but do not:
Barred controls. A disabled required field, a readonly required text field, a hidden required input, or a type="button" submit-like element contributes nothing. Test this with a quick mental model: if you can't tab to it or it isn't a data-bearing control, it usually isn't a candidate. Controls not associated with the form. An input outside the form and without a form="id" attribute is not the form's candidate. Its required is irrelevant to that form. novalidate. The form-level novalidate boolean attribute disables interactive validation on submit for the whole form. formnovalidate. A submit button with formnovalidate bypasses interactive validation for that activation, useful for "Save draft" buttons. type="submit" vs. other buttons. Only a submit button triggers submission; a type="button" button with a click handler that calls form.submit() bypasses validation entirely—because form.submit() (the method) does not run constraint validation, unlike user-initiated submission. This is a frequent source of "the form submitted with empty fields" bugs.
The form.submit() distinction is worth stating plainly: programmatic form.submit() skips validation; form.requestSubmit() (where supported) runs it. If you want validation in script-driven submission, use requestSubmit() or call checkValidity()/reportValidity() first.
Custom Validity Is Part of the Aggregate
setCustomValidity("message") makes a control invalid with validity.customError === true. Clearing it with setCustomValidity("") restores the control. Custom validity is a common reason a form is invalid even though no built-in constraint appears violated—for instance, a "passwords must match" check implemented by setting a message on the confirmation field. There is no form-level setCustomValidity; custom errors live on controls, but they propagate to the aggregate because the control is a candidate.
A subtle point: setCustomValidity on a barred control (e.g., disabled) does not affect the form, because barred controls aren't candidates. Teams occasionally set a custom error on a hidden field and are surprised that submission proceeds.
Radio Buttons and Checkboxes
Groups behave specially. A required radio group is invalid only if none of the group's radio buttons is checked; the invalid event fires on the last radio in the group for reporting purposes. For checkboxes, required means the single checkbox must be checked. There is no native "at least two of these" constraint; that requires custom validation.
Ambiguity: "Set to Invalid" vs. "Styled Invalid"
The question may be about when the form (or its fields) becomes visually invalid, i.e., gets the :invalid pseudo-class. This is related but not identical:
A control matches :invalid whenever its constraint validation fails, at any time, not only on submit. A freshly loaded page with an empty required field can already match :invalid in CSS. A common UX pattern is to gate styling behind a :user-invalid pseudo-class (where supported) or a JavaScript flag set after the first submit attempt, so empty fields aren't red on load. :invalid follows the control's own validity, not a stored form-level state.
So if by "set to invalid" you mean "styled as invalid," the answer is "as soon as its constraints fail," which may be immediately on page load. If you mean "blocks submission," the answer is "on submit (or explicit validation call), when at least one candidate fails."
Historical and Compatibility Notes
Constraint validation is broadly supported in modern browsers. Some details vary:
minlength/maxlength on textareas and the tooShort state have had uneven historical support; check target browsers if you rely on them. The invalid event does not bubble in some older engines; modern Chromium, Firefox, and Safari bubble it, but capturing at the form is a safer pattern. :user-invalid is newer and not universally available; feature-detect or use a class-based approach. The willValidate property and the exact set of barred elements follow the spec but have had minor engine differences; test on your targets.
Practical Checklist for Debugging "Why Is My Form Invalid?"
1: Confirm the control is associated with the form (form attribute or DOM containment) and is a candidate (not disabled, not readonly where barred, not hidden/button/reset). 2: Check control.validity and control.validationMessage on each candidate; look for customError first if you use setCustomValidity. 3: Remember form.submit() bypasses validation; use requestSubmit() or call reportValidity(). 4: Check for novalidate on the form or formnovalidate on the activating button. 5: For radio groups, check that some radio is checked when required. 6: Confirm pattern regex anchors and escaping; an unanchored pattern can surprise you (pattern is implicitly anchored as if wrapped in ^(?:...)$ for the whole value in most engines, but behavior with newlines and edge cases is worth testing).
Summary
An HTML form is treated as invalid for submission when a validation pass over its candidate controls finds a failure—triggered by user-initiated submission (absent novalidate/formnovalidate) or by explicit checkValidity()/reportValidity() calls. There is no persistent form-level "invalid" flag; individual controls carry validity, and the form is only the aggregate. Visual :invalid styling is separate and can appear before any submit. The most common false alarms come from barred controls (disabled/hidden/readonly), from form.submit() skipping validation, and from custom validity set on controls that aren't candidates. Once you know which controls are candidates and when validation actually runs, "when is the form invalid?" becomes a precise, testable question rather than a mystery.