Text inputs

Introduction

It’s important to keep HTML5 valid text inputs, keeping accessibility in mind.

  • Input type needs to match the type of data that will be entered.
  • Field labels should always be valid HTML labels and never placeholder text
  • Required fields should have a red asterisk (*) AND have bold label text
  • When the user has existing data to choose from, do not use a text input. Use a dropdown field instead.
  • Messages (error or valid) should be in close proximity to the field in question. These are displayed directly underneath the field, and should be descriptive and useful for the user

Design

Text field

Required text field

Email field (required)

Phone number field

Textarea

Validation and error messages

Validation should happen automatically after the user interacts and then leaves the field in question. Error messages need to be descriptive and helpful. (not “there was an error”)

Error message

This is an error

Valid field

Validation success message example.

Code

Standard text field HTML

Required text field HTML

Error message

Success message