Well I was just checking some HTML5 code, I felt like sharing something which will be beneficial for peoples new to web development. Whenever you create any web-form like registration from, comment form, feedback form etc there are fields that are required and must be filled by the user. For example you are creating a registration form and required fields are:
- First Name
- Last Name
- Mobile Number
You can check the LIVE DEMO.
Here is the small code that can help you in creating great web-forms
<html> <body> <form action="welcome.php"> First Name: <input type="text" name="firstname" required="required" placeholder="First name" /></br> Last Name: <input type="text" name="lastname" required="required" placeholder="Last name" /></br> E-mail: <input type="text" name="email" required="required" placeholder="E-mail" /></br> Mobile Number: <input type="text" name="phone" required="required" placeholder="Mobile Number" /></br> <input type="submit" value="Submit" /> </form> </body> </html>
NOTE: Some old browsers doesn’t have support for HTML5 including older versions of Internet Explorer.
Most of the web browsers have support for HTML5 so you can opt for using HTML5 and feel its power. For other older browsers you can use a jQuery plugin named jQuery.html5form which will enable browsers to execute HTML5’s form validation. I have not tested this plugin but you can use and comment here.
I hope this short and simple tutorial will help someone in someway 😉