
Originally Posted by
Ruberto
I came across a bug while implementing my field copy script. On a particular form I kept getting an "undefined error". I also noticed that the values in the editable fields were all offset from the way they should have rendered (i.e. the bottom value in the top field). After some head scratching I discovered the deviant. It is the <fieldset></fieldset> tag. Javascript sees it as a form element but doesn't seem to know what it is. The element.type method returns "undefined". I cannot find anything about this in the JS documentation. Anybody know how to deal with this problem?
If I cannot find a way to trap out the errant object then I'll have no choice but to stop using <fieldset> in my forms.
Thanks!
Ruberto
Well, you haven't specified where this comes up in the code but, there should be a relatively easy way around it. A fieldset has no type attribute but, some browsers might think that it does. So, you need to find a way to either skip it gracefully or to count it either for for what it is or as just something in the form. For example:
Code:
if (element.type||(element.tagName&&element.tagName.toLowerCase()=='fieldset'))
will return true if the element has a type attribute and/or is a fieldset. While:
Code:
if (element.type&&(element.tagName&&element.tagName.toLowerCase()!='fieldset'))
will return false for a fieldset even if the browser thinks it has a type attribute.
Other tests can be devised to deal with fieldsets in whatever way you decide that you need to.
Bookmarks