Javascript detect Caps Lock key active or disactive when input password string into textbox

Javascript detect Caps Lock key active or disactive when input password string into textbox

Come rilevare lo stato del tasto Caps Lock (maiuscolo) da un campo di input textbox. 

<html> <head> <title>CapsLock</title> <script language="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'; } </script> </head> <body> <FORM> <SPAN><input type="password" name="txtPassword" onkeypress="capLock(event)" /> <SPAN><div id="divMayus" style="visibility:hidden">Caps Lock is on.</div> </FORM> <script language="Javascript"> capLock(window.event); </script> </body> </html>

Download DetectCapsLock.zip (502,00 bytes)

Lascia un commento

Il tuo indirizzo email non sarĂ  pubblicato. I campi obbligatori sono contrassegnati *

Are you human? Time limit is exhausted. Please reload CAPTCHA.

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.