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 3 of 3

Thread: help!!

  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Singapore
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help!!

    hi, i'm doing a login page for administrators. When the admin have entered the user name, password and have chosen the organisation which they are in, they would click the Log-In button to continue. Is there any way that when the admin have entered all the details and he/she just have to press Enter on the keyboard to continue instead of clicking the Log-In button?
    thanks!

    here's my code, it's a jsp file:

    <html>

    <head>
    <title>Administrator Login</title>

    <script language="javascript">

    function checking(name, password) {

    if(name.length==0) {

    window.alert("Please enter user name!");

    document.login.user_name.focus();

    } else if(password.length==0) {

    window.alert("Please enter password!");

    document.login.user_pass.focus();

    } else {

    login.submit();

    }

    }

    </script>

    </head>

    <body onLoad="document.login.user_name.focus()">

    <center>
    <h1><font color="blue">Administrator Login</font></h1>
    </center><hr><br>

    <br><br>

    <form name="login" action="admin_check.jsp" method="post">

    <table align="center">

    <tr>
    <td><b>User name :</b></td>
    <td><input type="text" name="user_name" size="15"></td>
    <tr>

    <tr>
    <td><b>Password :</b></td>
    <td><input type="password" name="user_pass" size="15"></td>
    </tr>

    <tr>

    <td><b>Organisation :</b></td>

    <td>
    <select name="org_options">
    <option>Cathay</option>
    <option>Eng_Wah</option>
    <option>Golden_Village</option>
    <option>Shaw_Brothers</option>
    </select>
    </td>

    <td align="right"><input type="button" value="Log-in" onClick="checking(document.login.user_name.value, document.login.user_pass.value)"></td>

    </tr>

    </table>

    </form>

    <br>

    <center>Note: User ID and password is <b>NOT</b> case-sensitive.</center>

    </body>

    </html>

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    changing this

    input type="button"

    to

    input type="submit"

    may do the trick
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    afaik, the onclick event should be changed into an onsubmit event, if the user hits enter, there wont be an onclick event anymore
    I am the luckiest man in the world


  •  

    Posting Permissions

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