Member-only story
Advanced Form Validation With Only HTML and CSS
Let’s build a simple form and look at all the HTML and CSS validation techniques we can use and then even submit the form!
Last week we built an advanced input field that was interactive and animated and even included some self-validation and we used no JavaScript at all!
The focus was mainly on the mouse and keyboard interactions and styling depending on validation states. But we can do much more than that!
This time we are adding validation to and submitting a form with just CSS and HTML:
Input fields provided by the browser
Normal input fields with type="text"
, as their name correctly suggests, allow you to type in some text. We can further clarify what kind of text we are expecting by requiring a certain number of characters to be entered before the input can be valid and the form be submitted. This can be defined with the minlength
and maxlength
attributes. We can also use the required
…