Validation is an important part of any web application or website. In HTML5 validation is very simple then earlier. HTML5 provides very simple and efficient way to validate any form.
In HTML5 "required" is the keyword to put in any form element to check, whether it has been chosen/selected/entered or not.
For validating a input type, we just have to use "required" keyword to check null value. See below-
<input name="arvind" type="text" required>
It is very simple in text input type. But it is not so in select input type.
Let see, how we implement in select in put type. Mechanism is similar but it require some more manipulation in select element.
To use it in select input type, we have to put the some value in all option of select input and first/top option value should be blank.
Let see below-
<select name="dept" required class="form-control">
<option value="">Select Department</option>
<option value="Bio-Informatics">Bio-Informatics</option>
<option value="Bioscience & Biotechnology">Bioscience & Biotechnology</option>
<option value="Chemical Engineering">Chemical Engineering</option>
</select>
Enjoy happy coding.
In HTML5 "required" is the keyword to put in any form element to check, whether it has been chosen/selected/entered or not.
For validating a input type, we just have to use "required" keyword to check null value. See below-
<input name="arvind" type="text" required>
It is very simple in text input type. But it is not so in select input type.
Let see, how we implement in select in put type. Mechanism is similar but it require some more manipulation in select element.
To use it in select input type, we have to put the some value in all option of select input and first/top option value should be blank.
Let see below-
<select name="dept" required class="form-control">
<option value="">Select Department</option>
<option value="Bio-Informatics">Bio-Informatics</option>
<option value="Bioscience & Biotechnology">Bioscience & Biotechnology</option>
<option value="Chemical Engineering">Chemical Engineering</option>
</select>
Enjoy happy coding.