js 密码为空显示错误
2024-09-05 09:13:13
<script>
var user = document.getElementById("user");
var pwd = document.getElementById("pwd");
var user_erro = document.getElementById("user_erro");
var pwd_erro = document.getElementById("pwd_erro");
//focus 获得焦点
user.addEventListener("blur", function () {
check_length(user); //传递参数
}, false);
pwd.addEventListener("blur", function () {
check_length(pwd);
}, false); function check_length(obj) {
var that = obj;
if (that.value.length < 1) {
that.style.borderColor = 'rgb(255, 76, 82)'; //为空
show_dom(that.id,"block");
} else {
that.style.borderColor = 'rgb(17, 194, 109)'; //不为空
show_dom(that.id,"none");
}
}
function show_dom(obj,disp) {
switch (obj) {
case "user":
user_erro.style.display = disp;
break;
case "pwd":
pwd_erro.style.display = disp;
break;
}
} </script>
最新文章
- Android编程思想双11口诀
- sqlserverJDBC驱动链接
- 使用zookeeper实现分布式锁
- HDU 4749 Parade Show(贪心+kmp)
- 小白学习mysql之函数
- linux 强大的编辑器之vi
- Windows之vmware安装破解版错误汇总
- linux配置Java(JDK)环境变量
- ubuntu编译openwrt前端web界面
- TOGAF架构开发方法(ADM)之需求管理阶段
- SpringMVC中的@Controller和@RequestMapping到底什么鬼?
- Python可视化库Matplotlib的使用
- codeforces 796A-D
- centos7 jmeter分布式安装
- jQuery-全屏滚动插件【fullPage.js】API 使用方法总结
- Web Workers文档
- 设置Linux终端字体颜色
- 雷林鹏分享:Ruby 发送邮件 - SMATP
- [转载]Android中Bitmap和Drawable
- 求子数组的最大和要求O(n)