Form Validation

Contributors: none

Design Problem

Users make mistakes. Users submit data for processing – but is the data truly "ready"? Be certain!

When users enter data into a form, it must be validated – such as checking for required values being present, or for reasonable values (such a dates containing year, month and day info) or reasonable formats (such as lastname-comma-firstname if that's required).

Users make mistakes. Well-designed forms help users by using sensible autocompletion, reasonable defaults, and unambiguous values (eg Months as 'Jan' rather than '01' etc.) Well-designed and consistent validation further enhance users' workflow.

  • Users may not always enter required information in an expected format – should a phone number contain non-numeric characters, spaces? Should it include a 'plus' with the international prefix?
  • Data that is not checked for sanity and validation errors may cascade into further corruption and take longer to detect and correct once entered. The best place to correct the information is before it's entered into the system, by the user doing the entry.
  • Without deliberate validation and intervention from Sakai developers, users might encounter cryptic system or database messages, leading to confusion (possibly discouraging usage and adoption of Sakai).

Solution

Improve upon the paper-form model. Web forms typically follow the mental model of a printed paper form that must be filled out, which is the main reason they are so successful – that is, users know what is expected, and what to do. However, interactive validation of forms should enhance the model rather than merely provide the recreation of a paper form. (See the related Responsive Disclosure pattern)

  • Validation should streamline workflow, instead of interrupting and interfering with it. Eliminate extra steps, such as re-entering data already entered; validation should provide as much help as possible so that the user can accomplish the task at hand with minimal distraction, minimal interruption.
    • Note that confirmation of email addresses or passwords often requires the user to enter the same things twice, but for good reason!
  • Required fields should be indicated in a consistent manner.
  • When fields fail validation:
    • Error messages should be descriptive – to provide enough information so that an attentive "newbie" could correct the problem. Examples might include "Title must have fewer than 30 characters. Title is currently 35 characters", or "Date 'available to' must be after date 'available from'".
    • Error boxes should be formatted in a consistent manner, so users instantly know "aha, this is an error message and I need to do something about it."
    • Whenever possible, parse the full form for problems and report all errors at once, instead of stopping to report just the first error encountered.
    • Error indicators should be in two places: all listed together at the top of the page for reference, and each inline with the fields that need attention.
      • All error messages should be located together in a page, as close to the main heading as possible. This allows users to see all problems at once to get a feel for the scope of work required to fix them – rather than seeing one error to correct, fixing it, and submitting the change – only to find there is another and then another and another.
      • Fields containing errors should have indicators inline: first, user attention is drawn to the fields that require fixes, and second, workflow is not hampered by requiring users to scroll up and down between error messages at the top, and a field towards the bottom. Ideally these inline indicators should be accompanied by extended descriptions to help the user identify and correct the problem in that field. These may be visible on the page or accessed via a mouseover tool tip on the indicator.
Source: Google

Use When

User-entered data can be injected into the system, and users can make mistakes. Any user-Entered data requires validation and "sanity checking" before submission of a form. This information needs to be presented in a logical and usable manner to enable the user to correct mistakes with minimal interruption.

How

TODO

Rationale

Users make mistakes. Well-designed forms help users by using sensible autocompletion, reasonable defaults, and unambiguous values (eg Months as 'Jan' rather than '01' etc.) Well-designed and consistent validation further enhance users' workflow.

  • Users may not always enter required information in an expected format – should a phone number contain non-numeric characters, spaces? Should it include a 'plus' with the international prefix?
  • Data that is not checked for sanity and validation errors may cascade into further corruption and take longer to detect and correct once entered. The best place to correct the information is before it's entered into the system, by the user doing the entry.
  • Without deliberate validation and intervention from Sakai developers, users might encounter cryptic system or database messages, leading to confusion (possibly discouraging usage and adoption of Sakai).

Accessibility Considerations

Specific tips related to error messages from form validation:

  • Color perception: Avoid using only colour to convey information. That is, use colour in addition to clearly labelled errors messages and success messages. (Red means "bad" but not everyone can distinguish red from green – so include the "bad" text as well.)
  • Navigation: Consider moving focus to the area on the page where an error occurred or providing a quick way for users to jump down to the problem.
  • Workflow: If multiple errors occurred, provide users with a summary or indication of the number of errors.
    • General techniques for form accessibility:

      • Labels: Clearly label form elements. Use the
      • Sequence: Ensure form fields are laid out in a logical order and can be easily controlled with the keyboard and other input devices. Use the "tabindex" attribute to provide convenient navigation when tabbing through form elements.
      • Sections: Group related form elements together using the <fieldset> tag.
18 Jun15:54

Validation

By Sami (not verified)

This is a good article about validation and what humans think when they fill out forms. It's very important to make sure your forms are filled with proper data or your data processing could crash when submitting the data and storing it to database. Red, green and yellow colors are good indicators when form is filled and the input is validated like gmail is doing.

29 Dec23:21

send me sample source code

By suri_295

iam interested to learn Ui pattern design .Please send me the sample code to explore.......

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <lh> <dl> <dt> <dd> <table> <tbody> <tr> <td> <em> <b> <u> <i> <strong> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>
  • Lines and paragraphs break automatically.
  • Glossary terms will be automatically marked with links to their descriptions. If there are certain phrases or sections of text that should be excluded from glossary marking and linking, use the special markup, [no-glossary] ... [/no-glossary]. Additionally, these HTML elements will not be scanned: a, abbr, acronym, code, pre.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.