Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Improve your forms using HTML5! (via) Anne Van Kesteren demonstrates the Web Forms 2 support in Opera 9—new form attributes include autofocus, required and type=email.

Tagged , , ,

2 comments

  1. Has anyone posted a screenshot which shows what Opera does when you try to submit a form without some information marked "required"? Is it very easy for a web page author to change whatever that behaviour is (some forms sometimes show red text by the missing information, some show an alert box, and some show a purple line at the top of the form)? Is there a new event which custom code can be bound to for when a form is submitted without meeting various requirements?

    Also, I don't really know much about client-side scripting, but if you have to add some javascript to do client-side validation on non-HTML5 browsers, won't that then completely override an HTML5-compatible browser's form validation anyway? Will there be any advantage to putting in a check for a browser's support of HTML5 and not running your own implementation, especially since that implementation will be customized to your specific form, and preferred means of alerting the user to missing information?

    Or is it planned that HTML5 will only be used when the client can be expected to support HTML5? I suppose that's how it was with HTML3->HTML4, but I've been spoiled by the (mostly) backwards-supporting XHTML (but I suppose it didn't have add any new HTML elements or attributes). Of course, I'm not saying this isn't worthwhile -- the day will come when all browsers will support HTML5 (and at least as many as currently support XHTML when served as XML, I suppose), and this will be a wonderful feature to not have to implement by hand or library every time, but I'm just curious about what happens in the meantime.

    N - 13th March 2007 18:57 - #

  2. You can catch the invalid event and cancel its default action to prevent the default behavior. You can tie some new message to that then.

    The advantage of having the markup do the validation for you is that in due course you'll no longer have to write the client-side validation. For users it's also better as they get consistent error messages from forms they're using throughout the web.

    I'm personally using it on some forms already, like the comment form on my weblog, to enable a better user experience for people who have an HTML5 enabled browser. (Previously it didn't have any validation at all.)

    Anne van Kesteren - 14th March 2007 11:22 - #

Sign in with OpenID

Auto-HTML: Line breaks are preserved; URLs will be converted in to links.

Manual XHTML: Enter your own, valid XHTML. Allowed tags are a, p, blockquote, ul, ol, li, dl, dt, dd, em, strong, dfn, code, q, samp, kbd, var, cite, abbr, acronym, sub, sup, br, pre

A django site