I just read a piece of code, I found that does not work, I use the MS IE6, but I did not open the capital key, press the letter also prompted
<Scr platinum pt>
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 = 'ddd ';
}
</Scr platinum pt>
<Input type = "password" name = "txtPassword" encrypted nkeypress = "capLock (event)"/>
<Div id = "divMayus" style = "visibility: hidden"> Caps Lock is on. </div>
Later, I suddenly thought of the toLowerCase () method. If the case key is on, the entered value must be different from the lower-case value. In this case, I don't know whether the upper-case key is on?
<Scr platinum pt>
Function capLock (){
Kc = event. srcElement. value;
If (kc! = Kc. toLowerCase ())
Document. getElementById ('divmayus'). style. visibility = 'visible ';
Else
Document. getElementById ('divmayus'). style. visibility = 'ddd ';
}
</Scr platinum pt>
<Input type = "test" name = "txtPassword" Export nkeyup = "capLock ()"/>
<Div id = "divMayus" style = "visibility: hidden"> Caps Lock is on. </div>
Two problems are found after writing. 1) the uppercase key is on, but if only a number is entered, no prompt is displayed. Fortunately, numbers are case-insensitive. 2) If you enter an uppercase letter, you will still be prompted even if the uppercase key is disabled, then I want to set only one variable to save the input, but it seems a lot of trouble.
Another way is to check the character entered at the end. The code hasn't been written yet. Let's talk about it later.