HTML5 Series - Forms

Forms haven't really changed in functionality since they were first invented, but with HTML5 the browser is going to add a lot of the functionality you've previously been hand coding through JavaScript/jQuery.

HTML5 now supports things like setting a field to be required or adding some html text that disappears when you click in the field. Some of the new tags include:

  • required - Determines if the field must be filled in
  • placeholder - Text to be displayed before the user enters a value
  • autofocus - Default the curser to the field with this set
  • pattern - A regex expression to validate the field
  • min / max - Specify the min and max values that can be entered

For more visit the HTML5 form attributes page on W3Schools

There are also new input types that will restrict the data that can be entered and the way the field is rendered such as:

  • colour
  • date
  • datetime
  • email
  • month
  • number
  • range
  • search
  • tel
  • time
  • url
  • week

For more view is the HTML5 form input types page on W3Schools