68 Chapter 3—Intelligent Forms
value attribute matches a nonempty character string. If this condition applies
(in other words, a value has already been entered), the counter variable count is
increased by one value. To finish, the maximum value of the progress element is
set to the number of all required fields and the value to the number of the non-
empty elements.
Two buttons are available for submitting the form: Save and Submit. We have
already discussed the save function in section 3.4.5, Or Perhaps Better to Not
Validate? “formnovalidate”; new in this context is the attribute accesskey:
<p><input accesskey=T type=submit formnovalidate
value="Save [S]" name=save id=save>
<input accesskey=T type=submit name=submit id=submit
value="Submit [T]">
Keyboard shortcuts are not new in HTML5, but they have not been used much
so far. One problem with keyboard shortcuts is that they are activated by differ-
ent key combinations on different platforms, so you never quite know which key
you are supposed to press for a particular shortcut. The HTML5 specification
has a suggestion to solve this: The value of the accessKeyLabel should return a
character string that corresponds to the correct value on the platform you are
using. You could then use this value in the button’s label or in its title attribute.
Unfortunately, at the time of this writing, not a single browser was capable of
outputting this character string.
Summary
The information we supply in this chapter explains many of the new options
provided in HTML5 for forms. Better times are ahead for web developers, be-
cause they will no longer need to grapple with JavaScript libraries for common
input elements, such as date and time. In particular, the new form functions will
be of great help when working with mobile devices where text input is usually
much more difficult than on the computer. Form validation in the browser will
also contribute significantly to making the code more transparent and therefore
more manageable. But do not forget that client-side validation does not make
the server application more secure; potential attackers can easily circumvent
these checks.
If this chapter has whet your appetite and you want to try out your freshly ac-
quired knowledge of forms on your own website, go right ahead. The syntax of
the new elements and attributes is built in such a way that even older browsers
will not produce errors. Users of such browsers will not be able to enjoy the full
benefit of the new input elements, but text input is always possible.