How can i detect caps lock key on/off using jquery.... I have a password textbox and i allow only small letters so i dont want caps lock key to be on....
Is it possible to detect the state of Caps Lock Key using jquery?
How can i detect caps lock key on/off using jquery.... I have a password textbox and i allow only small letters so i dont want caps lock key to be on....
Is it possible to detect the state of Caps Lock Key using jquery?
What I do is put up a warning when
It's a pretty bad idea to only allow smaller letters. You're cutting down the number of possible passwords by a tremendous amount by doing that.
How to detect Caps Lock with Javascript.
function capLock(e){
kc = e.keyCode?e.keyCode:e.which;
sk = e.shiftKey?e.shiftKey:((kc == 16)?true:false);
if(((kc >= 65 && kc <= 90) && !sk)||((kc >= 97 && kc <= 122) && sk))
document.getElementById('divMayus').style.visibility = 'visible';
else
document.getElementById('divMayus').style.visibility = 'hidden';
}
then for your password form:
<SPAN><input type="password" name="txtPassword" onkeypress="capLock(event)" />
<SPAN><div id="divMayus" style="visibility:hidden">Caps Lock is on.</div>
After the user has created their password, when they’re entering it during login, you could just convert it to lowercase on the server before checking whether it’s correct.
Saves effort for the user that way.