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>
<script src="//"></script>
    $(function() {
        var sAllowableCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
            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);

    <label>Phone Number:&nbsp;<input id="txtText" /></label>

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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=""></script>
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.
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.
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Dave BaldwinFixer of ProblemsCommented:
I am to type anything in that box in Firefox 38.0.1.  However, it says that '$' is not defined.
Mukesh YadavFull Stack DeveloperCommented:
How are you running this code using server or simply opening with browser?
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.
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.
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.
Dave BaldwinFixer of ProblemsCommented:
Firefox apparently doesn't think there are any errors either.
elepilAuthor Commented:
Yes, Dave, but why aren't the keyed inputs appearing as it does with IE, Chrome, and Opera?
Dave BaldwinFixer of ProblemsCommented:
I find it confusing but apparently 'keyCode' is being removed from javascript.

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.
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

From novice to tech pro — start learning today.