»
EnglishFrenchVietnamese

Print - Check Cap Locks - JavaScriptBank.com

Full version: jsB@nk » Utility » Check Cap Locks
URL: https://www.javascriptbank.com/check-cap-locks.html

Check Cap Locks © JavaScriptBank.comIf a user enters his JavaScript password in a Web-based form with Caps Lock accidentally on, he can become frustrated because his JavaScript password is not being accepted... and he may assume the application is the source of the problem. This JavaScript code function will let the user know his Caps Lock is on and about the potential for error.

Full version: jsB@nk » Utility » Check Cap Locks
URL: https://www.javascriptbank.com/check-cap-locks.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// jgw (jgwang@csua.berkeley.edu ) | http://www.csua.berkeley.edu/~jgwang/<!-- Beginfunction checkCapsLock( e ) {var myKeyCode=0;var myShiftKey=false;var myMsg='Caps Lock is On.\n\nTo prevent entering your password incorrectly,\nyou should press Caps Lock to turn it off.';// Internet Explorer 4+if ( document.all ) {myKeyCode=e.keyCode;myShiftKey=e.shiftKey;// Netscape 4} else if ( document.layers ) {myKeyCode=e.which;myShiftKey=( myKeyCode == 16 ) ? true : false;// Netscape 6} else if ( document.getElementById ) {myKeyCode=e.which;myShiftKey=( myKeyCode == 16 ) ? true : false;}// Upper case letters are seen without depressing the Shift key, therefore Caps Lock is onif ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {alert( myMsg );// Lower case letters are seen while depressing the Shift key, therefore Caps Lock is on} else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {alert( myMsg );}}//  End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<FORM><STRONG>Password:</STRONG><INPUT TYPE="Password" NAME="Password" SIZE=16 MAXLENGTH=16 onKeyPress="checkCapsLock( event )"><P><INPUT TYPE="Reset"></FORM><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->