www.webdeveloper.com
Results 1 to 2 of 2

Thread: key press event code not running in mozilla

  1. #1
    Join Date
    Apr 2007
    Location
    uk
    Posts
    26

    key press event code not running in mozilla

    hi all,

    i wrote code to block alphabets in a input text box, this is working perfectly in IE, but when I tried with mozilla fire fox its not working properly.

    this is the code I used...
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    <html>
    <head>

    <script type="text/javascript">

    if(navigator.appName!= "Mozilla")
    {

    }
    else{document.addEventListener("keypress",keyhit,true);}


    onload = function(){
    field = document.getElementById('number_field')
    field.onkeydown = keyhit
    field.focus()
    }

    function keyhit(e)
    {
    thisKey = e ? e.which : window.event.keyCode

    if(thisKey == '65' || thisKey == '66' || thisKey == '67' || thisKey == '68' || thisKey == '69' || thisKey == '70' || thisKey == '71' || thisKey == '72' || thisKey == '73' || thisKey == '74' || thisKey == '75' || thisKey == '76' || thisKey == '77' || thisKey == '78' || thisKey == '79' || thisKey == '80' || thisKey == '81' || thisKey == '82' || thisKey == '83' || thisKey == '84' || thisKey == '85' || thisKey == '86' || thisKey == '87' || thisKey == '88' || thisKey == '89' || thisKey == '90' )
    {
    event.returnValue = false;
    alert ('alphebets r not allowed');
    }
    }



    </script>

    <title>increment field</title>
    </head>
    <body>

    <form action="" method="post">
    <p><input type="text" id="number_field" name="number_field" value="0"></p>
    </form>

    </body>
    </html>

    please help me as soon as possible, thanks in advance...
    micprasanna

    Getting into Heaven is not about what you've done, it's about what God's done.
    www.eonswww.com

  2. #2
    Code:
    if(navigator.appName!= "Mozilla")
    {
    do what?
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles