Wierd Condition!

Discussion in 'PHP' started by MichaelLewis, May 6, 2008.

  1. #1
    Can anyone review my following code and tell me what's wrong with it. I've wasted a day trying to figure it out and just can't find the problem.

    When the 5 comment rows are changed to code (i.e., when I remove the "//"), I get an "error in the page" message when my localhost sends the file to my browser. I'm sure ther is nothing wrong with the code. It seems to be a syntak error but I just can't see it.

    function mytab(fld,to,len)
    {with (fld,to,len)
    {if (fld.value.length==len)
    {if (fld.name==\"mmfr\" || fld.name==\"mmto\")
    {if ((fld.value.charCodeAt(0)<48 || fld.value.charCodeAt(0)>57) || (fld.value.charCodeAt(1)<48 || fld.value.charCodeAt(1)>57))
    {alert(\"Invalid Month (not numeric).\");}
    else {if (fld.value > 12)
    {alert(\"Invalid Month.\");}
    else {if (fld.name==\"mmfr\")
    {if (((fld.value == 4 || fld.value == 6 || fld.value == 9 || fld.value == 11) && document.getElementById('ddfr').value > 30) || fld.value == 2 && document.getElementById('ddfr').value > 29)
    {alert(\"Invalid Day for Month or visa versa.\");
    document.getElementById('ddfr').focus();}
    else {to.focus();}
    }
    }
    // else {if (((fld.value == 4 || fld.value == 6 || fld.value == 9 || fld.value == 11) && document.getElementById('ddto').value > 30) || fld.value == 2 && document.getElementById('ddto').value > 29)
    // {alert(\"Invalid Day for Month or visa versa.\");
    // document.getElementById('ddfr').focus();}
    // else {to.focus();}
    // }
    }
    }
    }
    }
    }

    MANY MANY THANKS
    Michael
     
    MichaelLewis, May 6, 2008 IP
  2. awatson

    awatson Active Member

    Messages:
    112
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    This is javascript, not php...
     
    awatson, May 6, 2008 IP