惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cisco Blogs
爱范儿
爱范儿
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
Jina AI
Jina AI
Project Zero
Project Zero
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
Simon Willison's Weblog
Simon Willison's Weblog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tenable Blog
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
Last Week in AI
Last Week in AI
月光博客
月光博客
雷峰网
雷峰网
G
Google Developers Blog
V
V2EX
T
Tor Project blog
罗磊的独立博客
Schneier on Security
Schneier on Security
Know Your Adversary
Know Your Adversary
W
WeLiveSecurity
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy International News Feed
S
Securelist
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
小众软件
小众软件
Scott Helme
Scott Helme
I
Intezer
T
Threat Research - Cisco Blogs
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
C
CERT Recently Published Vulnerability Notes
Security Archives - TechRepublic
Security Archives - TechRepublic
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LINUX DO - 最新话题
N
News | PayPal Newsroom
L
Lohrmann on Cybersecurity
T
Troy Hunt's Blog
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
Latest news
Latest news
AWS News Blog
AWS News Blog
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - chengbo

Android Studio:为Android定制的IDE 使用Gitolite来对Git的repository实现权限控制 用Debian当路由,来解决BT造成的网络慢的问题 更快的,更好的支持硬件的模拟器 当LISTVIEW有HEADER时,ONITEMCLICK里的POSITION不正确 准备再写写东西了 压缩 ViewState 后,与 UpdatePanel 的兼容问题 - chengbo 如何让 firefox 的窗口大小不再被网页脚本改变 52个行之有效的减压方法 如何用C#和SQL获得当前月的第一天和最后一天 每天如何自动编译项目并将之打包添加到VSS中 - chengbo - 博客园 maxthon 2 预览版的邀请 成都古羌科技有限公司招聘 怎样用TSQL建JOB xml参数存储过程 如何在ReadOnly的DataGrid中的让CheckBox列可点击 激情黄健翔 Head first design patterns 读书笔记 – Strategy(策略模式) 双击U盘出现“拒绝访问”的解决方法
用Javascript检查Caps Lock是否按下
chengbo · 2007-01-25 · via 博客园 - chengbo

在输入密码的时候,用户不看键盘的话很难知道自己是否启用了大写,所以到经常因为大小写错了而被系统拒之门外。

其实一段js代码就可以解决这个问题。

<script>
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 
= 'hidden';
}
</script>

<SPAN><input type="password" name="txtPassword" onkeypress="capLock(event)" />
<SPAN><div id="divMayus" style="visibility:hidden">Caps Lock is on.</div>

试试效果吧。

原文