Impress your Web Visitors with real-time Form Validation

Form ValidationThe first impression you usually have as a user of a Web Application is when you fill out a web form. I’m amazed at the number of web forms out there that have zero validation or that wait for you to submit your form contents before telling you what problems that you might have.

My rule of thumb is that anything that is not validated is supported. Anything that can be validated prior to submitting the form must be. With the advent of Ajax, you can even validate data against your database prior to submission. Don’t pick the lazy route – users appreciate the help!

Here are some examples:

  1. Email Addresses – I don’t mind forms that make you fill out your email address twice to validate them, but the fact that they don’t tell you whether or not they match or are constructed appropriately is inexcusable.
  2. Passwords – If you’re going to make me type in a password twice, then please validate that the values are the same before posting the form.
  3. Password Strength – If you require a certain password strength (combination of alphanumeric characters or cases), then provide some feedback for me while I’m typing my password in. Don’t wait for me to submit before telling me it failed.
  4. Dates – If you’d like the date in a m/d/yyyy format, then allow me to enter the information in a single field by typing those values and formatting them appropriately. If you want leading zeros, put them in after. It’s okay to display one format and save another in your database.
  5. Today’s Date – Fill it out for me! Why are you asking me to fill in the date when you already know it?!
  6. Date Format – If you have an international application, you can default a date format based on Internationalization of your application. Of course, it’s good to have an option for users to override that option and select their own.
  7. Social Security Numbers – it’s pretty simple to add some javascript that automatically jumps from field to field or programmatically put a dash in between values.
  8. Telephone Numbers – taking Internationalization into consideration, these types of fields also can be simplified by formatting the telephone number in the interface, but saving it in another format that’s efficient for your back-end. Don’t make your users type in parenthesis, spaces, and dashes.
  9. Maximum Text Length – if you limit the number of characters stored in your database, then DON’T let me type that many characters in! It doesn’t even require difficult validation… it’s just a setting on the textbox.
  10. Minimum Text Length – if you require a minimum text length, then sound the alarm until I have enough characters.

Here’s an example of a Password Strength function from Geek Wisdom:

Type the password:

UPDATE: 10/26/2007 – I found a neat resource with a JavaScript library available for download for form validation, called LiveValidation.