trouble with onkeydown

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • George Hester

    trouble with onkeydown

    This element is the only disabled=false element on the form:

    <HEAD>
    ....
    <SCRIPT type="text/javascript">
    <!-- Begin
    function ValidateKey(e);
    e = event || window.event;
    var key;
    var skey;
    if (document.layer s){
    key = e.which;
    skey = e.which;
    } else {
    key = e.keyCode;
    skey = e.keyCode;
    }
    alert(key);
    // ...
    return (true);
    }
    // End -->
    </SCRIPT>
    ....
    </HEAD>
    <BODY onload="JavaScr ipt:document.fo rms['frm1'].elements['1'].focus(); ...."
    ....
    <FORM id="frm1" ...>
    <INPUT id="1" type="text" onkeydown="Java Script:Validate Key();" ..../>
    ....

    When the document loads a message comes up which says 0. This seems wrong to me since no key was pressed. I understand why though. But what makes it worse is that if the message box is OK'd and the user types ANY character key such as m; p; t;... but not either of the ctrl keys or alt (those kind) on the keyboard, a message box comes up that says 0.

    And then the issue is compounded because if the user OK's that message box and types another character, those that I described above then no message box; which is what I expect in the whole procedure here. The first one I can deal with but my "what makes it worse" is really uncalled for and I cannot figure out how to get the first key entered to not return 0. Thanks.

    --
    George Hester
    _______________ _______________ ____
  • HikksNotAtHome

    #2
    Re: trouble with onkeydown

    In article <OMpLb.128923$J W3.90359@twiste r.nyroc.rr.com> , "George Hester"
    <hesterloli@hot mail.com> writes:
    [color=blue]
    >
    >This element is the only disabled=3Dfals e element on the form:
    >
    ><HEAD>
    >...
    ><SCRIPT type=3D"text/javascript">
    ><!-- Begin
    >function ValidateKey(e);
    > e =3D event || window.event;
    > var key;
    > var skey;
    > if (document.layer s){
    > key =3D e.which;
    > skey =3D e.which;[/color]

    <--snip-->

    Here I go with the 3D's again.

    Suggestion: In the future, it might be best if you give a URL to a test page
    and in the test page, include the problem. If you don't see the 3D's above then
    I guess my point is moot, but know I see them here as well, as in most of your
    posts.

    Not asking you to change your OE settings, but try to be friendly to those of
    us who don't use OE?
    --
    Randy

    Comment

    Working...