Why oh Why

Discussion in 'JavaScript' started by oo7ml, Oct 18, 2007.

  1. #1
    Hi, i have a simple contact form (name, email, message) that has JS validation on it. However, it does not seem to work in FF but it works perfect in IE.

    In FF, it only picks up if the name field is blank, and not the validation on the email or message field, however in IE it works perfect for all fields. Can someone please take a look as i have spent ages trying to figure it out and i am getting no where, thanks

    site url: http://simoncasey.ie/joc/contact.html
     
    oo7ml, Oct 18, 2007 IP
  2. Jamie18

    Jamie18 Peon

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    my guess is that when the validate_name function returns true the form gets submitted.. comment out the validate_name function and see if the e-mail field becomes the only one to be validated..
     
    Jamie18, Oct 18, 2007 IP
  3. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Firefox has a built-in JavaScript console that shows any script errors on the page you open (go to Tools => Error Console).

    This is the error message I got:
    "contact is not defined"
    on this line:
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(contact.email.value))
    Code (markup):
     
    phper, Oct 18, 2007 IP
  4. ezpz

    ezpz Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think in FireFox you need to qualify the form name - try

    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test([COLOR="Red"]document.[/COLOR]contact.email.value))
    Code (markup):
     
    ezpz, Oct 18, 2007 IP
  5. oo7ml

    oo7ml Well-Known Member

    Messages:
    656
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #5
    thanks guys
     
    oo7ml, Oct 19, 2007 IP