Created
September 6, 2017 12:42
-
-
Save rmpel/1626a90dacc7276b0052d9b6757e636c to your computer and use it in GitHub Desktop.
User friendly zip-code input, for DUTCH zip-codes. Gebruikersvriendelijke postcode invoer. (iOS getest)
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
| (function($){ | |
| $.fn.input_zip = function(){ | |
| return $(this).on('keyup', function(e){ | |
| if ($(this).val().length >= 4) { | |
| $(this).attr('inputmode', 'text'); | |
| $(this).attr('type', 'text'); | |
| } | |
| else { | |
| $(this).attr('inputmode', 'numeric'); | |
| $(this).attr('type', 'tel'); | |
| } | |
| $(this).blur(); | |
| $(this).val( $(this).val().toUpperCase().replace(/[^0-9A-Z]+/, '') ); | |
| $(this).focus(); | |
| }).trigger('keyup').attr('maxlength', 6); | |
| } | |
| $("input[type=zip]").input_zip(); | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment