Named Inputs

So, I’ve found myself leaving the ‘name’ attribute off of form elements recently…mostly due to laziness since I’m not using them (I know, I know…unobtrusive, and accessibility). We’re doing an RIA in a closed environment, so we can make the assumption/requirement that the client has javascript enabled. So, most of our stuff is leaning heavily (not quite obtrusively…but it is required) on javascript…and we use css and behaviour to identify the elements in the page and dwr to communicate back to the server. Works fine…great even. The problem is that it isn’t easy for the testers to test it with their robots. My first reaction is that the robots should be smart enough to find the elements by css (like we do)…or at least if it cannot determine a unique css selector for it, ask the tester to provide one (most appear to be automated, text-based scripts). But then again, this would also say to me than any screen readers would have trouble too. Since we aren’t concerned with accessibility (at least to the level of screen readers), that doesn’t bother me too much. The testing problem really does. So, we’re going to need to (at some point…hopefully soon) go back and name all our form elements (or maybe do something automated).

Anyway this whole post was triggered because I noticed that firefox’s ‘form cache’ feature (where if you refresh a page…not reload…just a simple refresh, then the form keeps the values you had in it…not sure if it happens on a back button use) gets confused when the form elements do not have names. I kept seeing values for field a (user name) showing up in field b (some date field).

Moral of the post: use names in the form elements…even if you dont ‘need’ them.

2 Responses to “Named Inputs”

  1. Nate Says:

    Plus if you are following XHTML standards, its required.

  2. james Says:

    Actually, no…it isn’t required. In both Xhtml 1.0 and 1.1 STRICT, the name attribute of an input is not required. Interesting though…I would have almost bet money that it was required.

Leave a Reply