摘要:Key press 大小寫提示功能
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtPwd" runat="server" onkeypress="javascript:KeyPress(this);" onkeydown="javascript:CloseDiv();" ></asp:TextBox><br/>
<div id="capslock" style="display: none; font-size:12px; color:Red; font-weight:bold; line-height:14px; padding-left:2px; padding-right:2px;">
您的鍵盤現在設定為大寫模式!可能造成您的密碼錯誤,您可按鍵盤上的Caps Lock鍵切回小寫!</div>
</div>
</form>
</body>
<script>
function KeyPress(objTR) {//只允許錄入數據字符 0-9 和小數點
var txtval = objTR.value;
var key = event.keyCode;
if (key >= 65 && key <= 90) {
document.getElementById('capslock').style.display = '';
}
else
document.getElementById('capslock').style.display = 'None';
}
function CloseDiv() {
document.getElementById('capslock').style.display = 'None';
}
</script>
</html>