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"/>
The pattern attribute of the <input> element allows you to add basic data validation without resorting to JavaScript. It works by matching the input value against a regular expression.
The simplest HTML validation feature is the required attribute. To make an input mandatory, add this attribute to the element.
Form validation can happen on the client side and the server side. Client side validation occurs using HTML5 attributes and client side JavaScript.
Validation-related attributesThe value must be greater than or equal to the value. There must be a value (if set). Unless the step is set to the any literal, the value must be min + an integral multiple of the step. The number of characters (code points) must not be less than the value of the attribute, if non-empty.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With