#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Portugal
    Posts
    53
    Rep Power
    13

    Question Two forms validation on same file - help


    Hi,

    I'm having a problem with form validation with the script I'l post bellow. Thanks in dvance for any help.

    I have one "Register" form and a "Login" form on the same page and when I try to login without entering any values, the alert bos shows the unfilled fields fo the "Register" form ?!

    How may I validate each one separately using the following script (I use in double, one for each form):

    <script language="JavaScript1.2" type="text/JavaScript1.2">
    function validate(login) {
    login=document.forms[0];
    var msgStr="";
    if(login.username.value=="") msgStr+=" No Username, \r\n";
    if(login.password.value=="") msgStr+=" No Password, \r\n";
    if(msgStr!="") {
    msgStr=msgStr.substring(0,msgStr.lastIndexOf(","));
    alert(msgStr);
    return false;
    } else {
    return true;
    }
    }
    </script>
    -----------------------------------------------------------------------------
    If a word can't save lives, silence may probably kill - Preventing suicide is your task to!...
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    This is the wrong forum for this

    Go post again in the HTML, Javascript & CSS forum.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Portugal
    Posts
    53
    Rep Power
    13
    Hi,

    Thanks for the post. It was a mistake
    -----------------------------------------------------------------------------
    If a word can't save lives, silence may probably kill - Preventing suicide is your task to!...

IMN logo majestic logo threadwatch logo seochat tools logo