HTML and CSS Reference
In-Depth Information
■
I'm using the opera browser to render the feedback form because it has the best support for the
new input types, as of this writing. I'll explain that more, later in this chapter. You can download opera from
Note
Reviewing the New Input Types
Now let's look at each of the new input types and see how they have been implemented in Opera. Keep in mind
that different browsers may present the control differently.
URL
The first field uses the
url
input type, which expects a valid web address. If you enter an invalid address, when the
page is submitted you'll see the validation error shown in Figure
2-14
.
Figure 2-14.
The URL field
■
The opera implementation automatically adds the
http://
prefix if the protocol is not included in the url. For
example, if you enter
www.apress.com
and tab off the field, the address is changed to
http://www.apress.com
.
Note
Selection List
The next field provides a dropdown list of available browsers. In ASP.NET this is coded as a
DropDownList
that
contains a number of
ListItem
elements. The generated HTML uses a
select
element that contains
option
elements like this:
<select name="Options" id="Options">
<option value="1">Internet Explorer</option>
<option selected value="2">Google Chrome</option>
<option value="3">Firefox</option>
<option value="4">Opera</option>
</select>
Notice that the selected item is indicated with the selected attribute. This is a boolean and doesn't need
a value so simply adding the selected attribute with no value is sufficient, although Visual Studio will show a
warning.