Required form fields in HTML5

One of many changes in forms that HTML5 is promising involves required form fields. In HTML 4 or XHTML, some scripting is needed to create a required form field.

With HTML5, there is a new attribute available for required form controls. The attribute is required. The browser or user agent will check on this and notify the user if the requirement is not met.

Here’s an example using an input element.

<label>Name: <input name="name" required></label>

Easy, right?

In HTML5, there is no need to use the syntax required="required". Dare I say it? In HTML5, all that’s required is required.

Leave a Reply