I know this questions is all over the place, but this is driving me crazy!!!
Here is my code:
$(document).ready(function () {
$('#MainContent_LoginUser_Password').keypress(function (e) {
noCapsLock($('#MainContent_LoginUser_Password'), e, "Please turn off Caps Lock");
});
});
function noCapsLock(o, e, str) {
var s = String.fromCharCode(e.which);
if (s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey) {
alert(str);
o.val('');
}
}
I am trying to clear the value of the textbox with the given id. The code above clears the text, but when a new key is pressed, the value of that key is shown (uppercase letters). I have tried the change(), keyup(), keydown() functions but they still do not seem to clear the textbox of the last value entered.
Any help will be appreciated. Thank you!