Search code examples
htmlformshtml4

HTML5 'Required' attribute for form validation: Good idea or bad idea


I am using the simplest of HTML 5 forms, and wish to use the 'required' attribute for the checkbox to make sure the user clicks it when submitting the form.

Should I have some server side validation - in case somebody is using a browser that doesn't support html5?

More Information:

My form looks like this:

[] I accept the terms and conditions

Submit

Code:

<input type="checkbox" required> I accept the terms and conditions<br />
<input type="submit" value="submit"/>

Solution

  • Client-side form validation is a good way for enhancing user experience, it also provides some styling that can help to communicate that an input is required.

    But you will allways still have to validate any data submitted on the server, making sure is clean and safe data. The required attribute can be manipulated by a malicious user.