Issue
I want to to prevent the user from entering uppercase text in a form input!! I tried removing the last char if it is uppercase, but the char appears before being removed.
Is there a way to stop the text from getting into the input in the first place?
Here is my code so far:
$('#s').keyup(function (){
var lastChar = $('#s').val().substr($('#s').val().length - 1);
if(lastChar.match('[A-Z]'))
{
$('#s').val($('#s').val().slice(0,-1));
}
});
Any ideas ?? Thx !!
Solution
Try keypress or keydown instead of keyup :)
Here's a working example: http://jsfiddle.net/YEKzA/
Answered By - Benno
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.