HTML and CSS Reference
In-Depth Information
Users can't enter any more than 50 characters into the text field with the maxlength set to
a value of 50.
In some cases, you might want to ensure that users enter only certain information in a
certain format.
url input type
The <input> type of url displays a text box similar to what the <input> type of text provides.
However, the renderer is instructed that the input type is url , so when users try to submit
a form with this type of information on it, it validates that the text in the box matches the
format of a valid URL.
EXAM TIP
You can validate data in many ways. Even more options become available in HTML5,
such as the url input type. Also available are the pattern attribute and the use of regular
expressions in JavaScript. Both of these are discussed later in this chapter.
The following code demonstrates a url type added to the survey:
<tr>
<td>Last Name:
</td>
<td>
<input type="text" id="lastNameText"/>
</td>
</tr>
<tr>
<td>
Your favorite website:
</td>
<td>
<input type="url"/>
</td>
</tr>
<tr>
<td>
Other Comments:
</td>
<td>
<textarea id="otherCommentsText" rows="5" cols="20"></textarea>
</td>
</tr>
<tr>
<td>
<input type="submit"/>
</td>
</tr>
 
 
Search WWH ::




Custom Search