HTML5 based Form Validation

HTML5 provides a builtin way of form validation by setting the type properties of the form elements. In the following code, 4 fields are validated using HTML5 based validation:

<form id="form1" name="form1" method="post" action="">
 <table border="1">
 <tr>
 <td>Select Date</td>
 <td>
 <input id="txtdate" name="txtdate" 
 type="date" />
 </td>
 </tr>
 
 <tr>
 <td>Select Date Time</td>
 <td>
 <input id="txtdatetime" name="txtdatetime" 
 type="datetime-local" />
 </td>
 </tr>
 
 
 <tr>
 <td>Email</td>
 <td>
 <input id="txtemail" name="txtemail" 
 type="email" />
 </td>
 </tr>
 
 <tr>
 <td>Enter URL</td>
 <td>
 <input id="txturl" name="txturl" 
 type="url" />
 </td>
 </tr>
 
 <tr>
 <td></td>
 <td>
 <input id="btnsubmit" name="btnsubmit" 
 type="submit" value="Submit" />
 </td>
 </tr> 
 </table>
</form>

 

Add a Comment

Your email address will not be published. Required fields are marked *