The novalidate Attribute
You'll learn how to disable the browser's built-in form validation to take full control with your own custom validation logic.
What It Does
When you add the novalidate attribute to a <form> element, you're telling the browser: "Don't run your automatic validation checks when this form is submitted." The browser will completely skip checking things like required, pattern, min, max, and all other constraint validation rules you've added to inputs.
Why Would You Disable Validation?
Think of it like turning off autocorrect on your phone because you're writing a custom spell-checker. The browser's default validation is helpful, but sometimes you need complete control:
- You want to validate fields as users type instead of only at submission
- You need custom error messages styled differently than the browser's default tooltips
- You're building a multi-step form where you validate only certain sections at a time
- You need complex cross-field validation (e.g., "end date must be after start date")
How to Use It
Simply add novalidate to your form tag:
<form novalidate>
<input type="email" required>
<input type="number" min="1" max="10" required>
<button type="submit">Submit</button>
</form>
Now when the user clicks "Submit," the form will submit even if fields are empty or invalid—because you've disabled the browser's checks. You must handle all validation yourself using JavaScript (with methods like checkValidity() and the Validity State object you've already learned).
Key Takeaway: The novalidate attribute disables automatic browser validation, giving you full responsibility to implement custom validation logic before form submission.