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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Key Press in Mozilla

    Hello,

    I have a login page and in Internet Explorer when the user hits enter they get logged in. This doesn't work in Mozilla and the user has to click the login button instead. Can anyone see why this might be in this js code?

    Code:
    function entsub(_event, _ourform) {
      alert("Login attempt: Highway");
        if (_event && _event.keyCode == 13)
          _ourform.submit();
        else
          return true;
      }
    Cheers,
    Ger

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Not without seeing how you catch the event.
    My script catches the enter key. See what's different between mine and yours.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Mine is being called from a jsp page using:

    Code:
    <tr>
            <td class="TDLABEL-REQ">UserID:</td>
            <td><input class="TEXT-REQ" type="text" onkeypress="return entsub(window.event,this.form)" size=15 name="userid" value=''> </td>
            <td>&nbsp;</td>
          </tr>
          <tr>  
            <td class="TDLABEL-REQ">Password:</td>
            <td><input class="TEXT-REQ" type="password" onkeypress="return entsub(window.event,this.form)" size=15 name= "userpassword" value=''> </td>
            <%   if (session.getAttribute("login") !=null) 
            		{   if (session.getAttribute("login").equals("fail")) { %>
            <td class="TDLABEL-RED-LEFT">
    		        	 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Login Failed! Please Try again.
            		 <%  } else if (session.getAttribute("login").equals("not")) { %>
            <td class="TDLABEL-RED">
    			         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Not Logged in! Please Login.                  
    		 		<%   } 
    		 		} else {%>		 		
            <td class="TDLABEL-BLACK-LEFT">
    		 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please Login 
       			<%   } %>
            
            </td>
          </tr>

  • #4
    New Coder
    Join Date
    Sep 2005
    Location
    Ottawa, ON
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    your passing in window.event as the first argument.

    window.event is an IE only thing. In every other browser the event object is a "stand alone" thing that just gets passed to the trigger by the browser when it's fired.

    do this instead

    in the onkeypress trigger write :
    Code:
    return entsub(event,this.form)
    and in the function do this:
    Code:
    function entsub(_event, _ourform) {
    //grab IE's window.event if it exists
    if (window.event) { _event = window.event; }


  •  

    Posting Permissions

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