Created
January 22, 2014 22:02
-
-
Save codexico/8568280 to your computer and use it in GitHub Desktop.
char list to accept from user
This file contains 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 inputOnlyLetters () { | |
var re_letters= /^[ ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZabcçdefghijklmnñopqrstuvwxyzàáãÃÀÁéèÈÉíìÍÌïÏóòõÕÓÒúùÚÙüÜ]+$/gi; | |
var re_not_letters= /[^ ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZabcçdefghijklmnñopqrstuvwxyzàáãÃÀÁéèÈÉíìÍÌïÏóòõÕÓÒúùÚÙüÜ]/gi; | |
$('.not-number').on('keyup', function() { | |
var input = this; | |
// user needs some time to write chars that need two strokes, like ç => ' + c | |
window.setTimeout(function(){ | |
if (!re_letters.test(input.value)) { | |
input.value = input.value.replace(re_not_letters, ''); | |
} | |
}, 800); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment