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
    Dec 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using Enter Key to activate

    I would like this script to be activated when the user hits the enter key. Now the user needs to click on the Log In button. What do I need to change?

    ++++++++++

    <form>
    <p><FONT FACE="Verdana,Tahoma,Arial,Helvetica,Sans-serif,sans-serif" SIZE="-1"><b> LOG IN HERE.</b></p>
    Username and Password are <b>CAsE sENisTIvE</b><br>
    <p>ENTER USERNAME :
    <input type="text" name="text2">
    </p>
    <p> ENTER PASSWORD :
    <input type="password" name="text1">
    <input type="button" value="Log In" name="Submit" onClick=javascript:validate(text2.value,"TEST",text1.value,"TEST") ></FONT>
    </p>

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

    /*
    Script by Anubhav Misra (anubhav_misra@hotmail.com)
    Submitted to JavaScript Kit (http://javascriptkit.com)
    For this and 400+ free scripts, visit http://javascriptkit.com
    */

    function validate(text1,text2,text3,text4)
    {
    if (text1==text2 && text3==text4)
    load('ing-gm.html');
    else
    {
    load('failure.htm');
    }
    }
    function load(url)
    {
    location.href=url;
    }
    </script>

  • #2
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Step one: Valid HTML.
    Step two: Format with CSS.
    Step three: Make sure the form responds without scripting enabled.

    Code:
    <html>
    <head>
    <script type="text/javascript">
    /*
    Script by Anubhav Misra (anubhav_misra@hotmail.com)
    Submitted to JavaScript Kit (http://javascriptkit.com)
    For this and 400+ free scripts, visit http://javascriptkit.com
    */
    function validate(text1,text2,text3,text4) {
        if (text1==text2 && text3==text4) {
            location.href = 'ing-gm.html';
        } else {
            location.href = document.forms[0].action;
        }
        return false;
    }
    </script>
    <style type="text/css">
    p {
        font-family: Verdana,Tahoma,Arial,Helvetica,sans-serif;
        font-size: 91%;
    }
    </head>
    <body>
    <form action="failure.htm" onsubmit="return validate(text2.value,'TEST',text1.value,'TEST');">
    <p><em>LOG IN HERE.</em></p>
    <p>Username and Password are <em>CAsE sENisTIvE</em></p>
    <p>ENTER USERNAME : 
    <input type="text" name="text2">
    </p>
    <p>ENTER PASSWORD :
    <input type="password" name="text1">
    <input type="submit" value="Log In">
    </p>
    
    </form>
    </body>


  •  

    Posting Permissions

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