View Single Post
  #1  
Old 23-07-2011, 07:07 AM
.BZU.'s Avatar
.BZU. .BZU. is offline


 
Join Date: Sep 2007
Location: near Govt College of Science Multan Pakistan
Posts: 9,693
Contact Number: Removed
Program / Discipline: BSIT
Class Roll Number: 07-15
.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute
Thumbs up How to Allow text box only for alphabets using Jquery

If you want to make the text box allow only alphabets (a-z) using Jquery. it is easy to do so...

HTML Code:
<input name="Texting" onkeyup="this.value=this.value.replace(/[^a-z]/g,'');">
OR for Smaller and Upper both cases


HTML Code:
<input name="First Name" type="text" id="fn" class="textbox" onkeyup="this.value=this.value.replace(/[^a-z,A-Z,.]/g,'');"/>
And can be the same to onblur for evil user who like to paste instead of typing

HTML Code:
<input name="lorem" class="alphaonly">
<script type="text/javascript">
$('.alphaonly').bind('keyup blur',function(){ 
    $(this).val( $(this).val().replace(/[^a-z]/g,'') ); }
);
</script>
You shouldn't use HTML attributes to attach events, especially when something as easy as jQuery is available to properly attach the event handler.
__________________
(¯`v´¯)
`*.¸.*`

¸.*´¸.*´¨) ¸.*´¨)
(¸.*´ (¸.
Bzu Forum

Don't cry because it's over, smile because it happened
Reply With Quote