My jQuery keyboard events not working with Firefox 38.0.1

This is weird. The following code snippet works fine with the latest versions of IE, Chrome, and Opera, but will not work with the latest Mozilla Firefox ver. 38.0.1. Can someone please tell me why?? Could this be a jQuery issue??
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
    $(function() {
        var sAllowableCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        $("#txtText").on({
            keypress: function(event) {
                var s = String.fromCharCode(event.keyCode);
                if (sAllowableCharacters.indexOf(s) === -1) {
                    return false;
                }
            },
            keyup : function(event) {
                var sInput = $("#txtText").val().trim();
                console.log("sInput=" + sInput);
            }
        });
    });

</script>
<style>
</style>
</head>
<body>    
    <label>Phone Number:&nbsp;<input id="txtText" /></label>
</body>
</html>

Open in new window

elepilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David H.H.LeeCommented:
Hi elepil,
What's error returned? Try add missing "http://" in your code.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
0
elepilAuthor Commented:
David, thanks for responding.

There is no error. Whatever you input simply doesn't appear if you run my code in Firefox. But it works fine with IE, Chrome, and Opera.
0
Mukesh YadavFull Stack DeveloperCommented:
Simply place your script tag after label tag.

In the current code element doesn't exists when you are trying to bind events input element.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Dave BaldwinFixer of ProblemsCommented:
I am to type anything in that box in Firefox 38.0.1.  However, it says that '$' is not defined.
0
Mukesh YadavFull Stack DeveloperCommented:
How are you running this code using server or simply opening with browser?
0
elepilAuthor Commented:
Guys, nothing's wrong with the jQuery CDN link. Just copy and paste the code snippet I provided to an empty HTML file, then run it. As long as you have an internet connection, that jQuery CDN will work.

Please test the code snippet first in IE, Chrome, or Opera. Then you'd know how it works. Then test it with Firefox and see the difference.
0
Dave BaldwinFixer of ProblemsCommented:
Interesting.  If I run your code as a "file://", it allows all characters in all browsers.  If I run it thru my web server, Chrome and IE8 only allow letters and Firefox doesn't allow anything.  And it doesn't show any errors except for two jQuery errors.
0
elepilAuthor Commented:
Dave, the reason it allows only letters is because I filtered it that way. That was the whole object of this exercise, to prevent the user from keying in characters I don't want. Aso why Firefox doesn't allow anything, that there is the original reason why I posted this.
0
Dave BaldwinFixer of ProblemsCommented:
Firefox apparently doesn't think there are any errors either.
0
elepilAuthor Commented:
Yes, Dave, but why aren't the keyed inputs appearing as it does with IE, Chrome, and Opera?
0
Dave BaldwinFixer of ProblemsCommented:
I find it confusing but apparently 'keyCode' is being removed from javascript.  https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
elepilAuthor Commented:
Thanks for your help, Davie. I'm closing this call, even though I didn't really get an exact solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.