-
Book Overview & Buying
-
Table Of Contents
HTML5 Data and Services Cookbook
By :
One of the most basic checks at the client side is the length of the text being inserted or submitted with the form. This is often left out, but it is one of the checks that must be done and not just at the client side. Imagine if we had no restriction on any of our inputs, a few large texts could overload the server without making much effort.
Let's create a simple HTML form that will contain a few different inputs on which we will apply some constrains:
Head of the page is a standard one, so we will directly go into creating the form, first adding the name input limited to 20 characters as follows:
<form>
<div>
<label>
Name <input id="name" type="text" name="name" maxlength="20" title="Text is limited to 20 chars"placeholder="Firstname Lastname" >
</label>
</div>After that we will add another input field that initially has an invalid value, longer than the one specified for testing purpose...
Change the font size
Change margin width
Change background colour