Caps Lock Detector / Warning Script

Simple javascript that detects and gives a warning message whenever your caps lock key is on.

Features

  • You can integrate with your webpage forms and password fields to warn the user about the status of his/her capslock key.
  • Enable your CAPS LOCK key and type into a field to see how this works.
  • If the caps lock is off then the script allows the user to proceed with their entry or else a warning message will appear.

Preview

Capslock Detector

Password:

Downloads

Javascript


<!-- Script by hscripts.com -->
<script type="text/javascript">
function checkCapsLock( e )
{
var fKeyCode=0;
var myShiftKey=true;var msg='You are pressing shift key or attempting to type in caps';
var myMsg='Caps Lock is On.';
if ( document.all )

{
fKeyCode=e.keyCode;
myShiftKey=e.shiftKey;
}
else if ( document.layers )
{
fKeyCode=e.which;
myShiftKey=( fKeyCode == 16 ) ? true : false;
}
else if ( document.getElementById )
{
fKeyCode=e.which;
myShiftKey=( fKeyCode == 16 ) ? true : false;
}
if ( ( fKeyCode >= 65 && fKeyCode <= 90 ) && !myShiftKey )
{
alert( myMsg );
}
}
function ctck()
{
var sds = document.getElementById("dum");
if(sds == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}
var sdss = document.getElementById("dumdiv");
if(sdss == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}
}
document.onLoad=ctck();
</script>
<!-- Script by hscripts.com -->


HTML Code


<!-- Script by hscripts.com -->
<form>
<strong>Password:</strong>
<input TYPE="Password" NAME="Password" SIZE=16 MAXLENGTH=16 onKeyPress="checkCapsLock( event )">
<input TYPE="Reset" value="clear">
<div align=center style='font-size: 10px; color: #dadada;' id="dumdiv"><a href="https://www.hscripts.com" id="dum" style='text-decoration:none; color: #dadada;'>
© hscripts.com</a>
</div> </form>
<!-- Script by hscripts.com -->

  • Release Date - 06-05-2010
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to support@hscripts.com

Usage

  • Copy and Paste the Html code into the <body> tag.
  • Then Copy the javascript code into <head> tag of your page.
  • The important portion is the onKeypress event call in the form, "onKeyPress=checkCapsLock( event )". Here we call the function checkCapsLock to check whether the caps lock is on or not.
  • Simple and ease of use detector script.

License

Related Scripts

Free Javascript Scripts


Ask Questions

Ask Question