The purpose of a form validation script is to return a boolean value ('s to reference form fields, but that can lead to namespace conflicts and why make things more complicated than necessary.
When the form is submitted - either by hitting Enter or clicking on the Submit button - the (the 'value' of the field called 'input' belonging to the form). In a real-life situation you will most likely have more fields to check, and more complicated conditions, but the principle remains the same.
We need to check if it is equal to null or “” because different browsers act differently so its better to check for both the conditions.
The first example shows how to validate a checkbox if nothing is checked.
This is similar to radiobutton example explained above.
In the case of a checkbox multiple values can be selected so validation is done if none of the checkboxes are ticked.
You can also validate by requiring the user to select a minimum of one value or two value according to your requirement.
When form input is important, it should always be verified using a secure server-side script.