Forms are a grouping of input controls that allow a user to submit information to your application.
Do
Properly mark fields as required
Add help blocks with inputs when necessary, especially when users may not fully understand the purpose of the input
Place constructive action buttons on the right, and deconstructive action buttons on the left of the form
If necessary, place short, related inputs on the same line (e.g., City and State, Start and End, Min and Max)
Ensure that unsaved changes are not easily lost
Don’t
Use placeholders as the only label
Place unrelated inputs on the same line
Form Field Labels
Do
Ensure that clicking on a label focuses the corresponding input
Use sentence capitalization for labels
Use concise label names
Be consistent with label positioning (above/beside)
Be consistent with questions or statements labels
Don’t
Use colons after labels
Example
Required Fields
Required fields should be marked as required.
Example
Form Validation
There are two main types of form validation, often used together.
Field level: Validation errors appear directly below the field with errors (e.g., This field is required.)
Form level: Validation errors appear at the top or bottom of the form (e.g., The email or password you entered is incorrect., and Please fix the 3 errors.)
For input fields that are cramped, you may need to resort to using a popover error message.
Do
Scroll to and focus the first field with an error when the submit button is pressed.
Provide validation feedback as soon as possible, either 500ms after a key is pressed, when the field loses focus, or (if all else fails) when the form is submitted.
Provide field level validation for fields that are known to be invalid
Provide form level validation for large forms, or when the system doesn’t know exactly which field is invalid
Describe why an error occurred (e.g., Email is already in use rather than There was an error)
Describe/imply what the user should do to fix the error
Don’t
Cause the form to ‘bounce’ as validation errors show/hide while the user is typing
Include technical jargon in errors
Alphabet Validation (no space)
Numeric Validation
Help Text
Help text can be placed at the top of the form, under the heading of a form group, under an individual form field, or as a popover when the field is focused.
Place help text at the top of the form to give information that relates to the entire form
Place help text under the heading of a form group to give information that relates to that form group alone
Place help text beside or under an individual form field that relates to that field alone
Use a popover on an input field (text box, text area, or select) for help text that is lengthy, complex, non-critical, or when screen real estate is limited. Too much help text can make a form look and feel busy and difficult.
Example
Input Character Limits
Most input fields have technical character limits. The system should handle this gracefully in all scenarios.
Text box
In most cases, simply ignore key presses that exceed the limit
Text area
If the limit is low or the expected input size is unknown, include a limit indicator
Update the limit indicator on each key press
Allow the user to keep typing past the indicator, but provide obvious indications that the limit has been exceeded.