'Ugh. Forms. It's the one thing in building web pages t...'

From the comments on 'Good Practice in Implementing HTML Forms'

Pete wrote:

Ugh. Forms.
It's the one thing in building web pages that I really hate doing.

I don't think it's necessarily true that one should avoid Ajax in forms. As with anything, it just needs to be done properly to add optional functionality.

The example of 'check username' is a good one. It's a useful thing, but it's also quite possible to set up so that if JS isn't available the 'check username' button doesn't appear.

Likewise, if the Ajax request fails, show a friendly message saying that the name couldn't be checked.

It's all about progressive enhancement. Make the form work, then (and only then) add stuff to make it work better and improve user experience.

Although I tend not to use Ajax for form submission, the same principle can be applied. Make the form work without the Ajax call, then (if you have the time and inclination) do the Ajax submission with some detection/fallback if the Ajax call fails.

On the subject of checkboxes, radio buttons and labels. I'm in a state of flux as to how exactly to mark up a group of radio buttons (for example).

Assuming that your form has a question/answer format do you use a legend tag and a fieldset to group your buttons together then apply labels to each radio button? Or do you group them in a div and put your question into a label for that div?
I can never decide!

Oh, yes, welcome back :)

View full discussion or Read the original article (Good Practice in Implementing HTML Forms)