Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
15
rated 0 times [  20] [ 5]  / answers: 1 / hits: 107225  / 14 Years ago, sat, june 5, 2010, 12:00:00

I want to make a text box allow only letters (a-z) using jQuery.
Any examples?


More From » jquery

 Answers
11
<input name=lorem onkeyup=this.value=this.value.replace(/[^a-z]/g,'');>


And can be the same to onblur for evil user who like to paste instead of typing ;)



[+] Pretty jQuery code:



<input name=lorem class=alphaonly>
<script type=text/javascript>
$('.alphaonly').bind('keyup blur',function(){
var node = $(this);
node.val(node.val().replace(/[^a-z]/g,'') ); }
);
</script>

[#96578] Wednesday, June 2, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aubriechantalr

Total Points: 380
Total Questions: 95
Total Answers: 86

Location: Guadeloupe
Member since Sat, Aug 22, 2020
4 Years ago
;