CKTIS / HTML
formnovalidate — bypass validation during form submission
The boolean `formnovalidate` attribute lets a submit button bypass automatic form constraint validation. It is useful for saving an incomplete draft without changing the fields' requirements.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
formnovalidate | formnovalidate="" | formnovalidate="formnovalidate"formnovalidate skips automatic constraint validation when a form is submitted through that button. It applies to button elements that act as submit buttons. An explicit type="submit" is not required: if a button with no type attribute acts as a submit button, formnovalidate applies to it too. The attribute also applies to input elements with type="submit" or type="image". It is not intended for an ordinary text field or a button with type="button".
This is a boolean attribute: its presence enables the validation bypass. Valid forms are formnovalidate, formnovalidate="", and formnovalidate="formnovalidate". Writing formnovalidate="false" is nonconforming and still leaves the attribute present; remove the attribute to turn this feature off.
novalidate on the form skips validation for the whole form, whereas formnovalidate applies to submission through a particular button. A button without formnovalidate cannot restore validation when the form has novalidate.
Skipping validation does not make invalid fields valid. An explicit call to checkValidity() still checks constraints. In the example, the submit handler prevents actual submission and displays the result of that check. Validate data on the server too: browser validation is not a security boundary.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>formnovalidate demo</title>
<form id="editor">
<label>Title <input name="title" required></label>
<button type="submit" value="publish">Publish</button>
<button type="submit" value="draft" formnovalidate>Save draft</button>
</form>
<pre id="result" aria-live="polite">No submission</pre>
<script>
const editor = document.getElementById('editor');
const result = document.getElementById('result');
editor.addEventListener('submit', (event) => {
event.preventDefault();
result.textContent = event.submitter.value
+ ': valid=' + editor.checkValidity();
});
</script>
</html>Result
draft: valid=false
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.