Check Cap Locks | JavaScriptSource

Check Cap Locks

John Wang Mar 6, 2002


If a user enters his password in a Web-based form with [Caps Lock] accidentally on, he can become frustrated because his password is not being accepted, and may assume the script is the source of the problem. This script will let the user know his [Caps Lock] is on and about the potential for error.



Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: checkCapLocks.js


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document

Leave a Response


Your question is beyond the scope of these comments. You will need to post it over on [a href=""]the JavaScript forum[/a]. Thanks!

Lee Oct 31, 2008

That's not a problem, that is the way it was designed to work. You can always adapt it to what you need.

Lee Oct 31, 2008

Hi ,[br /]The Main problem with ur script is checking only for the capitalized word not the caps lock button is pressed .

Narasimhan Oct 22, 2008

Hi[br /][br /]I'm italian so my english is not the best but i hope u 'll understand me[br /][br /]Your code is cool but when i apply it in my website there's an error: 'Object Required'[br /][br /]- I followed your instructions:[br /][br /]- I pasted scipt tags on the <head> tag[br /]I wrote onkeypress="checkcapslock(event)" on the textbox tag[br /][br /]can u help me?

Fabio Di Tommaso Oct 22, 2008

In order to better help you, you'll need to post your question [a href=""]over on the forums[/a].

Lee Jun 26, 2008