Form Validation with HTML5
==========================
On the :ref:`Text Inputs ` page, we looked at
*client-side validation*. By changing the ``type`` attribute in the ````
tag, we make the browser perform a quick check of the data entered into a
field. Types like ``number``, ``email``, ``date``, etc. compare the data from
an input box to a particular format. However, these checks do NOT prevent a
user from leaving an input blank.
The ``required`` attribute prevents form submission if the user skips one or
more of the input fields. It flags any input that returns the empty string
(``""``) as its value.
``required`` lets us place an emphasis on the most important information we
need to collect from a form.
.. admonition:: Example
The ``Name`` and ``Student ID`` fields are necessary, but ``Favorite Color``
can be left blank.
.. sourcecode:: html
:linenos:
.. figure:: figures/required-field.png
:alt: The empty Name and Student ID fields are flagged with a red border.
After trying to submit the form, red borders flag the empty, ``required`` fields.
The ``required`` attribute also works for non-text inputs as well.
#. **Radio buttons**: Only *one* ``required`` attribute is needed for the
group. This group consists of all ``input`` elements that share the same
``name`` attribute.
.. sourcecode:: html
:linenos:
#. **Select element**: Place the ``required`` attribute inside the ``