# HTML Form Attributes & Validation
# HTML5 Form Validation
While we're handling the form backends of your forms, you may want to validate them before you publish to make sure your users enter the correct data.
Even though it is still not being supported in some browsers (opens new window), HTML5 gives you a lot, from marking fields as required, to size limits, to ensuring emails look like emails. Here are the most common validations:
- MDN: Form data validation (opens new window)
- HTML5 validation browser support (opens new window)
- MDN: the input element (opens new window)
We recommend using HTML5's built-in validation. It is very rich these days, and has good browser support.
# Required Attribute
This input type, when present, specifies that an input field must be filled out before submitting the form.
<input type="text" name="message" required>
# Email Attribute
This input type guarantees an email address is formatted correctly.
<input type="email" name="email">
# Number Attribute
This input type ensures a number with a range.
<input type="number" min="18" max="99" value="30" name="age">
# URL Attribute
This input type guarantees a URL is formatted correctly.
<input type="url" name="website">
# Length Attributes
With these attributes, you can limit the characters in a text input or textarea.
<input type="text" maxlength="10"> <textarea minlength="20"></textarea>