Created
July 24, 2014 17:52
-
-
Save karschsp/f817e2b295f5b89fb20c to your computer and use it in GitHub Desktop.
heynow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery('input.capture_mailingAddress_postalCode').attr('maxlength', '25'); | |
| $("input.capture_mailingAddress_postalCode").keypress(function(event) { | |
| // Backspace, tab, enter, end, home, left, right | |
| // We don't support the del key in Opera because del == . == 46. | |
| var controlKeys = [8, 9, 13, 35, 36, 37, 39]; | |
| // IE doesn't support indexOf | |
| var isControlKey = controlKeys.join(",").match(new RegExp(event.which)); | |
| // Some browsers just don't raise events for control keys. Easy. | |
| // e.g. Safari backspace. | |
| if (!event.which || // Control keys in most browsers. e.g. Firefox tab is 0 | |
| (49 <= event.which && event.which <= 57) || // Always 1 through 9 | |
| (48 == event.which && $(this).attr("value")) || // No 0 first digit | |
| isControlKey) { // Opera assigns values for control keys. | |
| return; | |
| } else { | |
| event.preventDefault(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment