Using both PHP and JavaScript to validate a form

Discussion in 'Programming' started by pictureboarduk, Mar 8, 2009.

  1. #1
    Hi,

    I am trying to validate a form with both JavaScript and PHP.

    I have wrote the validation scripts, but when I submit the form, the javascript is not creating an Alert box when I test it.


    The form is as follows:

    ......

    I have the insert.php file and the javascript embedded within the page.

    The javascript does cause invalid fields to turn yellow, but no Alertbox pops up. Javascript is not blocked any my browsers.
    This is the entire register.php:

     
    pictureboarduk, Mar 8, 2009 IP
  2. yoes_san

    yoes_san Peon

    Messages:
    443
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You forgot ";" on the third line here?

    if (fld.value.length == 0) {
    fld.style.background = 'Yellow';
    error = "The required field has not been filled in.\n"; //semi colon here
    }
     
    yoes_san, Mar 9, 2009 IP