[thelist] PHP/html form queston: a better way to do this form and submission?

Ian Anderson ian at zstudio.co.uk
Thu Aug 11 11:20:12 CDT 2005


Bruce Gilbert wrote:

>Hello,
>
>I am working on a form which uses PHP to submit the info. to an email
>address. For an instance like a phone number I  have the html mark-up
>like this with different input values for the area code, 3 digit exchange and
>last 4 digits. and then you check the values of each and post either
>the results or an error.
>  
>
 From an accessibility standpoint, this arrangement is far from ideal,

1. Your for attribute in the initial label text doesn't relate to any 
element in the code you posted, so that could cause problems
2. You don't have labels for 2 (strictly speaking, 3) of the three form 
elements

Each form field must have its own label. Use fieldset and legend to 
group related fields together

>Posting 'You didn't enter your " .$fieldname " might be confusing if
>the fieldname is "last_four_digits" so, I was hoping of a more
>simplified way to do this type of information in my form.
>  
>
With visible label text, you can make your error messages much more user 
friendly

>Also is there a way for the form to automatically go to the next field
>once a certain amount of info. has been entered? eg: after putting in
>3 digits for the area code, the cursor will automatically jump to the
>next field?
>
This is reported to cause problems for screen reader users, and I would 
avoid it.

To be honest, why do you need three form fields? People with and without 
disabilities are used to typing it out in one go. Why force people to 
put it into three separate fields? This is bad usability. Many people 
try to type the whole thing into the first field because no one reads 
form instructions.

If you need to break it down to validate the three parts, surely - given 
the format of US phone numbers - you can do this programmatically?

I assume there is no chance of users from outside the USA having to use 
this form, because the validation you are talking about will prevent 
them from proceeding with valid European phone numbers.

Hope this helps

Cheers

Ian



More information about the thelist mailing list