SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)

    Fieldset causing DOM issues

    Note: You need to be using a Mozilla browser for this. It is not intended to work in IE.

    I've been playing on and off with a form and validating it using JavaScript and the DOM. You can see an example of it working here. Play around with it. Submit blank forms, change values, etc...

    A few days ago someone posted a link showing how to use CSS with the <fieldset>, <legend>, and <label> tags to make a pretty form (that's also XHTML 1 compliant). Unfortunately, upon removing the tables that originally gave my form it's, well, form, and using the <fieldset> tag I now get an error. I removed the <fieldset> tags without changing anything else and it then works so that is how I determined this is the problem.

    You can see an example of the form in its present state here. The javascript error occurs on line 144.

    Is there either a solution to this that I am just unaware of? Or any kind of a workaround? Or do I have to rethink how I am doing this?

  2. #2
    SitePoint Addict
    Join Date
    May 2004
    Location
    Europe
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mozilla adds the fieldset to the form.elements collection, and a fieldset element doesn't have a property type. No big problem though, just change line 144 (and all other lines where you test type.length > 0) to
    Code:
                            if (ele[i].type) {

  3. #3
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Perfect answer! Very much appreciated.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •