Q:

Validating an email address on key-press using javascript & jquery

I'm trying to prevent users from inputting invalid characters when typing-in an email address.  I am NOT trying to validate the entire value as-a-whole (that happens later).
I "thought" this was the correct way to prevent a list of characters (such as # or $):
/[A-Z0-9a-z@]^[$#<>?]/

This part works:
/[A-Z0-9a-z@]/

This part fails:
/^[$#<>?]/

Any thoughts?

A:

Try /[^$#<>?]/ instead.
The ^ inside and at directly after the opening bracket makes the class negative.
You can learn more about this on regular-expressions.info
Or better, heres a workign simple regex that does it, using yours as a start.
http://jsfiddle.net/hG99U/1/

A:

FIXED:
The problem was some keynum values collide with undesirable characters.  This fixed it!
// **********************
// .emailOnly
// Use -
// Makes the element email-only.
//
// Example -
// $('.myElement').emailOnly();
// **********************
(function($) {
    $.fn.extend({
        emailOnly: function() {
            return this.each(function() {
                return $(this).keypress(function(e, text) {

                    var keynum;
                    var keychar;
                    var regEx;
                    var allowedKeyNums = [8, 9, 35, 36, 46]; // Backspace, Tab, End, Home, (Delete & period)

                    if (window.event) // IE
                        keynum = e.keyCode;
                    else if (e.which) // Netscape/Firefox/Opera
                        keynum = e.which;
                    else
                        keynum = e.keyCode

                    keychar = String.fromCharCode(keynum);
                    regEx = /[^$#<>?]/ // Undesirable characters

                    // Test for keynum values that collide with undesirable characters
                    if ($.inArray(keynum, allowedKeyNums) > -1)
                        return regEx.test(keychar);

                    regEx = /[A-Z0-9a-z@]/
                    return regEx.test(keychar);
                });
            });
        }
    });
})(jQuery);

