Before moving to example please go through the part 1 of the series,
In this article you will learn about simple HTML 5 attributes, HTML 5 input element types and parse user input data to server side using Ajax call.
Using simple registration form I just implemented it.
HTML 5 attributes
- Autocomplete
Usually we use “autocomplete mode” beginning in the form. Doing that it applies all the input types under form tag.
Using autocomplete mode, browser automatically detect and complete rest of the values based on values that the user has entered before.
Although if you want to set “autocomplete" mode to off in specific input type you can simply set autocomplete="off" after that browser will not complete that input automatically.- <form autocomplete="on" id="user-RegInfo">
- <input type="text" class="form-control" id="user-FirstName">
- <input type="text" class="form-control" id="user-Email" autocomplete="off">
- </form>
- Autofocus
When web page get loads <input> element should automatically get focus,In a web page, only one input element should have the autofocus attribute applied,- <input type="text" class="form-control" id="user-FirstName" autofocus >
- Form
When you have one or more input types you need to add under form tag. - pattern (regexp)
Using pattern attribute you can specially set what is the accepted input values <input> elementsBelow I added few pattern:- <input type="text" class="form-control" name="country_code" pattern="[A-Za-z]{4}" title="Four letter country code" id="user-CountryCode">
a. used to check email pattern=" [^@]+@[^@]+\.[a-zA-Z]{2,6}"
b. Three letter Country code pattern=" [A-Za-z]{3}”
c. Enter Digits only pattern="\d{1,9}"
d. Sri Lankan phone number pattern="(\+?\d[- .]*){10}"
e. Strong Password pattern = “(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{10,}”
(at least ten symbols containing at least one number, one lower, and one upper letter) - Placeholder
Simply placeholder attribute provide hint of an input field. It’s more like title attribute but better than title attribute.- <input type="text" class="form-control" id="user-LastName" placeholder="Please enter Last name">
- <input type="text" class="form-control" name="country_code" pattern="[A-Za-z]{4}" title="Four letter country code" id="user-CountryCode">
- Required
This is a very important attribute. Because without filling input field user not able to submit the form.
When it comes, the front end validation required attribute plays major roll, because instead of having lengthy JavaScript validation you can have simple required attribute to do that part.- <input type="text" class="form-control" id="user-FirstName" required>
- Step
Step attribute only use with number input type. Using step attribute you can set intervals between two numbers. In example you need to go 5 by 5 in text box.- <input type="number" class="form-control" step="5" id="user-TeamMembers" required>
- min and max
This attribute also use with number input type.
Using min and max attributes you can specify minimum and maximum value to particular textbox.- <input type="number" class="form-control" min="0" max="20" step="2" id="user-TeamMembers" required>


Santhakumar MunuswamyPosted Jan 23, 2016, 1:43 AM
Thanks for nice share
Anu VPosted Jan 22, 2016, 11:17 PM
good article
Jaco ZwartsPosted Jan 22, 2016, 11:56 AM
Nice article keep on posting!