Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Username login help

    Hello everyone,

    I am trying to do a username login for my webpage with Javascript and I can only get one user in, I have tried to add on various other users and it does not work. Could anyone lend me a hand in figuring this out, I want to add other usernames and passwords and I simply am not accomplishing it. Whoever can help me I would greatly appreciate it.

    God Bless!

    Will

    Here is the Code:


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Javascript Test</title>
    <style type="text/css">
    <!--
    .style1 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    }
    -->
    </style>
    </head>

    <body class="style1">
    <form>
    <p>ENTER USER NAME :
    <input type="text" name="text2">
    </p>
    <p> ENTER PASSWORD :
    <input type="password" name="text1">
    <br>
    <input type="button" value="Check In" name="Submit" onclick=javascript:validate(text2.value,"free",text1.value,"javascript") >
    </p>

    </form>
    <script language = "javascript">

    function validate(text1,text2,text3,text4)
    {
    if (text1==text2 && text3==text4)
    load('http://www.yahoo.com');
    else
    {
    load('failure.htm');
    }
    }
    function load(url)
    {
    location.href=url;
    }
    </script>
    </body>
    </html>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Welcome to the forum, I see you did not read the bold text that siad this forum is for completed scripts not questions. A moderate will most likely move this....

    I am too lazy to run your code, but I see a flaw in how you are referencing the form field values.

    You should reference them like
    document.formName.elementName.value

    an not

    elementName.value

    you do not have a name with your form either...you could use the form array, but it is better to have a name.

    AND finally

    when using evernt handlers like onclick you do not need javascript:
    onclick='validate(.....)'

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •