SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Password Check Hitting Enter?

    Ok, I posted this before but to be honest I lost the thread, so I'm asking again.

    I put in a very simple JavaScript password check into a page that I am doing. The problem, However is that you have to actually hit the submit button to get it run, if you just hit enter nothing happens. The client wants it to run when you hit enter not the button. I've tried looking for information on this problem but haven't found anything. I could use some advice on this.

    Here is my code if this will help:

    <html>
    <head>
    <title>Password Check</title>
    <script language="JavaScript" type="text/javascript">
    <!--

    var bad_password = true

    function check_password() {


    var password_value = document.forms [0].user_password.value
    if (password_value) {

    bad_password = false


    document.images ["checker"].src = password_value + ".gif"
    }
    }
    function test_password () {


    if (!bad_password) {


    var password_value = document.forms[0].user_password.value
    self.location = password_value + ".htm"
    status = ""
    }
    }
    function password_error() {


    bad_password = true


    document.images["checker"].src = "smartmed1.gif"

    status = "Password rejected"
    alert ("Sorry your password is incorrect")
    status = ""
    }
    //-->
    </script>
    <style type="text/css">

    body
    {
    background-color: #000000
    }

    </style>
    </head>
    <body>
    <img src="teitablelogo.jpg"></img><br>
    <div>
    <font color="red">&nbsp;&nbsp;PASSWORD CHECK</font></div><br><br>
    <form>
    <input type="password" name="user_password">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" value="Enter your password" onClick="check_password()">

    </form>
    <img src="smartmed1.gif"
    name="checker"
    height="1"
    width="1"
    onLoad="test_password()"
    onError="password_error()">
    <div>
    <font color="red">THIS PAGE IS SECURITY ENABLED.<br>
    YOU ARE ATTEMPTING TO ACCESS THE PRIVATE PLAN ROOM FOR SMART MEDICAL TECHNOLOGY</font></div>
    </body>
    </html>

    As you can tell it just uses a simple gif replacement check.

    Thanks
    Jodi

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Do not test this code in Firefox.
    This code will KILL your browser.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    pmw,

    I have tested this in both FireFox and IE and it doesn't by hitting enter in either. You may want to check either your computer or browser settings in FireFox it does absolutely nothing to mine in Firefox nor to anyone else that has looked at it.

    Jodi


Bookmarks

Posting Permissions

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