SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    forms grrrrrr!!!

    I'm trying to learn javascript for form validation and have a javascript example from the Nov issue of the dmxzone e-magazine and am attempting to add more fields for an application. The form and script are at http://www.timegroupone.com/test/ . If you click submit with no fields filled in it detects all empty fields in IE(6 and 7) but fails to detect the select boxes in Opera and Firefox (an alert box indicates they are "undefined" in O and FF).

    From my CSS knowledge I know if it works in IE and not in FF I have done something wrong - any suggestions or help would be appreciated.
    Last edited by btimms; Jan 17, 2008 at 16:53. Reason: typo in the url

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by btimms View Post
    If you click submit with no fields filled in it detects all empty fields in IE(6 and 7) but fails to detect the select boxes in Opera and Firefox (an alert box indicates they are "undefined" in O and FF).
    I don't get any error messages but in the code you have assigned the same element "wav" to two different variables, however that isn't the cause of your problem.
    This code doesn't take account of the fact that Mozilla considers newlines to be child elements. You need to remove all the newline characters in the area of the selects and the surrounding divs, i.e. all tags adjacent to each other.
    Tab-indentation is a crime against humanity.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Logic Ali View Post
    I don't get any error messages but in the code you have assigned the same element "wav" to two different variables, however that isn't the cause of your problem.
    This code doesn't take account of the fact that Mozilla considers newlines to be child elements. You need to remove all the newline characters in the area of the selects and the surrounding divs, i.e. all tags adjacent to each other.
    Wow! Thanks! That explains why I was showing a text node in the FF DOM inspector that I couldn't figure out. After removing the newline characters it works - code not as readable as I'd like but this is one I won't easily forget.

    Also - thanks for the heads up on the double use of a variable (prob some cut/paste errors)


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
  •