Fancy Forms: HTML5 + CSS3 – JS

Forms in HTML have typically been pretty boring – input boxes and buttons with all validation performed by javascript. With the new HTML5 Forms module things have become a little more useful. As of May 2010, only bleeding edge browsers support this, Webkit Nightlies, Chrome Dev Channel builds and Opera.

The HTML5 forms module started out as Web Forms 2.0 before moving into HTML5. The focus has been to increase the number of input types and to allow validation of input to happen in the browser, rather than in javascript.

HTML5 Form Demo

In this demo I’ve set up a simple form with a number of different fields, the code should be pretty self explanatory, but there are a couple of new features of interest.

  • New input types – email, url, number and range
  • New pseudo classes – :valid, :invalid:, :required
  • You can’t submit the form until all fields are counted as valid by the browser

I’ve also added a few CSS3 touches to make things a little nicer to look at:

  • CSS transitions and transformations
  • :not pseudo class

Things to try

  • Submit the form without completing it
  • Notice that the browser checks whether the input is valid
  • The iPhone offers different keyboards depending on the input type
  • Check what it looks like in older browsers (fine, but no validation)

The code is commented where interesting, so take a look at the source.

HTML5 Form Demo

56 thoughts on “Fancy Forms: HTML5 + CSS3 – JS

  1. That is nice, practical, useful stuff, not just flash. Thanks for highlighting it.

    Though “even num < 10″ accepts 10. Shouldn’t it accept only up to 8? Smaller than 10, not equal too?

  2. I’ve been meaning to replace the whole blog with a series of flat files instead to enable easier demos. I like the idea that it’s easy for people to view the source without any distractions. On my list of things to do!

  3. Pingback: (번역) 지금 바로 모든 브라우저를 지원하는 HTML5 form 만드는 방법 « 엔지피클~ nzPickles

  4. Pingback: (번역) 지금 바로 cross-browser HTML5 form 만드는 방법 « 엔지피클~ nzPickles

  5. Excellent work! Just what I was looking for.

    I can see it work on iPhone Emulator.
    But the Android emulator is not working (fully).
    It does not show the check and cross icons. So validation is not working.

    Am I doing something wrong on Android.

    I can see it running on both Chrome and Safari.

  6. hi

    first this is great.

    i have some question i hope you can help me with.

    1- from where comes the tooltip? and how can i change the error messages? i mean i have cleaned the form from all javascript and the tooltip still work but i cannot see from where it comes. are you using some.

    2- can we use html 5 and css 3 from now? the form does not really work in FF as in chrome and not to mention IE :(

    again this is very creative and effective for user usage.

  7. Where are the source files for this demo? Appreciate if you can point me to them.

  8. Pingback: 10 Awesome HTML5 and CSS3 based Form tutorials | Webdesign ne.ws

  9. Pingback: HTML5 and CSS3 Form References, Resources and Tutorials

  10. Pingback: Web Development articles, tutorials, help » Blog Archive » HTML5 and CSS3 Form References, Resources and Tutorials

  11. Pingback: HTML5 and CSS3 Form References, Resources and Tutorials | Content Store

  12. Pingback: HTML5和CSS3表引用,资源和教程 | Q1前端开发

  13. Really nice example of an html 5 form. I have picked up a few tips from this that I will be using soon on my websites.

    By adding an ID to each of the inputs will enhance this slightly further. Making the ID the same as the label’s “For”, will make the input focused when the label is clicked.

  14. Pingback: 30 Helpful Tutorials How to Creating HTML5/CSS3 Forms | Pros Global TV

  15. Pingback: HTML5和CSS3表单示例和详细教程 | 百锐网

  16. Pingback: 20+ Best Html5 Forms | Best Wordpress Host

  17. Pingback: HTML5和CSS3表单示例和详细教程 | 托尼 Web前端开发| HTML , CSS & JavaScript

  18. Pingback: 20 Awesome HTML5 Web Forms Tutorials

  19. Pingback: 基于CSS3技术的强大WEB表单 | HTML5和CSS3

  20. Pingback: 110 Best CSS3 Tutorials and Examples | PriteshGupta.com

  21. Pingback: 分享16个优秀的 CSS3 表单开发教程 | 自由 开源 分享

  22. Pingback: 一亩三分地 | 分享16个优秀的CSS3表单开发教程

  23. Pingback: 16个优秀的CSS3表单开发教程 » 云暄传媒 — 网站建设 工作室 web开发

  24. Pingback: CSS3HTML5 » 分享16个优秀的CSS3表单开发教程

  25. Pingback: References, Tutorials and Resources of CSS3 and HTML5 Forms | DesDevWeb

  26. Pingback: 22个实用的HTML5 CSS3表单开发教程 | isir me

  27. Pingback: Blogging Well » Blog Archive » HTML5 and CSS3 Form References, Resources and Tutorials

  28. Pingback: 16个优秀的CSS3表单开发教程

  29. What does this mean? action=formdemo.php. I dont see any code which handles the submit button. How come the values are shown below with array of values?

  30. Pingback: 17 Best Html Contact Forms - Design Freebies

  31. Pingback: 14 CSS3 Form Tutorial - Design Freebies

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>