This problem came to me today. I'm working in a web-based (Struts 2) project with lots of JSPs, and most of input, select, table and a elements are defined with only with the name attribute, no id set, such as:
<input name="myname" class="myclass" value="" type="text"/>
So far so good, except that unfortunately there's a lot of javascript validation for those fields, and as far as I could read the code before leaving most of them actually refer to the elements with document.getElementById.
The catch here is that this is an old application (not that much old actually) only compatible with IE-6 and IE-7 (I didn't searched the net in order to understand how IE actually seems to find the element only with the name attribute, but I guess it must do something). No surprise every other single browser complains and cries.
So, I'm trying to come up with a simple solution: look up all JSPs that defines input, select, table and a elements with the name attribute but not id in order to fix the HTML.
Using my good ol' friend http://rubular.com I came up with the following:
/<(?:(input|select|a|table))\s+((?!id).)*>
This will catch every referred element without id. But how can I actually assert that only those with name are matched?
Oh, another important point. The definition of the elements are in a single line, so it's most probable that there arent't such things as:
<input name="..."
class="..."/>