Re: An accessible way to format Date and Social Security Number form fields?

Jennifer Gauvreau wrote:
> The question is when to prefill the hyphen, slash, dollar sign, and/or 
> comma. The team proposed three options:
> 
> 1. As user is entering their value
> 
> 2. After the user enters their value and the focus is lost from the field.
> 
> 3. After saving the entry to the database.

Step 3, because that's the most stable way of doing it. Steps 1 & 3 
create a dependency on JavaScript, and more annoyingly, change the data 
while it is being entered. This can create confusion when the user is 
editing or checking data they've just entered.

For the date format, specify the order (e.g. 'dd/mm/yy'), but allow the 
separator character to be anything, or not used. The backend should be 
able to find matches using regex - something like \d{2}\D?\d{2}\D?\d{2}.

The key is for the backend to be able to deal with any date thrown at it 
- where it is unambigious. When a date is ambigious, then there's an 
error on the form, so send the form back and ask the user to correct the 
date so that it isn't so ambigious -- but give them back the data as 
they entered it.


The same for the social security number, accept with and without the 
dash, and if your backend needs it with a dash, then format it with a 
dash when its missing just prior to storing the information in the database.

The idea is to be flexible with what's being entered - parse it, and if 
it makes sense, store it. If it doesn't make sense, then send it back to 
the user.

Received on Sunday, 2 November 2008 10:42:18 UTC