|
help me int his..,
<script type="text/javascript">
function isCapslock(e) {
e = (e) ? e : window.event;
var charCode = false;
if (e.which) {
charCode = e.which;
} else if (e.keyCode) {
charCode = e.keyCode;
}
var shifton = false;
if (e.shiftKey) {
shifton = e.shiftKey;
} else if (e.modifiers) {
shifton = !!(e.modifiers & 4);
}
if (charCode >= 97 && charCode <= 122 && shifton) {
return true;
}
if (charCode >= 65 && charCode <= 90 && !shifton) {
return true;
}
alert("CpasOn");
//return false;
}
</script>
<asp:TextBox ID="Password" runat="server" TextMode="Password" Width="150px" onkeypress="return isCapslock(this)"
></asp:TextBox>
if i press caps lock button nor not it gives me the message Capslock is on...,?
|
|
|
|
|
There's a blog post here ^[^] that claims to detect Caps Lock, but I haven't tried it.
Personally I like this solution[^] which just checks if the character entered is in Caps. If it is, and the ShiftKey is pressed, then Caps Lock is probably on
var s = String.fromCharCode(e.which);
if ( s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey ) {
alert('caps is on');
}
|
|
|
|
|