
六位独立密码框
发布日期:2021-05-10 16:26:47
浏览次数:22
分类:精选文章
本文共 2638 字,大约阅读时间需要 8 分钟。
找了好多独立密码框架,都有各种各样的bug,自己完善的密码框,希望能有人能用上!
html代码:
<div class="content">
<form action="" method="get" id="pass_input"> <div class="input_box"> <span>支付密码:</span> <div class="box"> <input type="text" name="" class="pass one" onselectstart="return false" autocomplete="off" οnfοcus="this.type='password'"/> <input type="text" name="" class="pass two" autocomplete="off" οnfοcus="this.type='password'"/> <input type="text" name="" class="pass three" autocomplete="off" οnfοcus="this.type='password'"/> <input type="text" name="" class="pass four" autocomplete="off" οnfοcus="this.type='password'"/> <input type="text" name="" class="pass five" autocomplete="off" οnfοcus="this.type='password'"/> <input type="text" name="" class="pass six" autocomplete="off" οnfοcus="this.type='password'"/> <i class="am-icon-eye-slash eyeBtn"></i> <div style="clear: both"></div> </div> <p class="hide">请输入六位数字密码</p> </div> <div class="content_input"> <button type="button" class="btn_dredge" οnclick="confirm()">确 定</button> </div> </form></div>
js代码:
/*密码组件*/
(function(){ var txts = document.getElementsByClassName('pass'); pass(txts);/*密码框*/ var icon = $(".eyeBtn"); var passEye = $(".pass"); eye(icon,passEye);/*眼睛操作*/ $(".one").focus(function(){ $(this).css("border-color","#51bef5") }) })();function pass(txts){
for (var i = 0; i < txts.length; i++) { var t = txts[i]; var _this = this; t.index = i; t.setAttribute("readonly", true); t.onkeyup = function (e) { if (e.keyCode == 8) { /*删除*/ if (this.value == "") { var prop = this.index - 1; if (prop < 0) return; txts[prop].removeAttribute("readonly"); txts[prop].removeAttribute("disabled"); txts[prop].style = "border-color:#51bef5"; txts[prop].focus(); this.setAttribute("readonly", true); this.setAttribute("disabled", true); this.style = "border-color:#ddd"; this.value = ""; } } else { if (this.value == "") { } else { reg = /^[0-9]*$/; /*填写*/ if (!reg.test(this.value)) { this.value = ""; return false; } this.value = this.value.substr(-1); var next = this.index + 1; if (next > txts.length - 1) return; this.setAttribute("readonly", true); this.setAttribute("disabled", true); this.style = "border-color:#ddd"; txts[next].removeAttribute("readonly"); txts[next].removeAttribute("disabled"); txts[next].style = "border-color:#51bef5"; txts[next].focus(); } } } } txts[0].removeAttribute("readonly");}//眼睛提示function eye(icon,passEye){ icon.mousedown(function () { icon.removeClass("am-icon-eye-slash").addClass("am-icon-eye"); passEye.attr('type', 'number'); }) icon.mouseup(function () { icon.removeClass("am-icon-eye").addClass("am-icon-eye-slash"); passEye.attr('type', 'password'); })}发表评论
最新留言
路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月05日 07时27分23秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Android--面试题整理(一)
2021-05-10
Android--消息摘要MD5,SHA加密
2021-05-10
python3 HTTP Error 403:Forbidden
2021-05-10
Java 中的多态详解
2021-05-10
linux系统下双屏显示
2021-05-10
关于高斯模糊核
2021-05-10
PDF.js —— vue项目中使用pdf.js显示pdf文件(流)
2021-05-10
vue解决数据更新,界面未更新的方法
2021-05-10
我用wxPython搭建GUI量化系统之wx.grid实现excel功能
2021-05-10
我用wxPython搭建GUI量化系统之wx.Toolbar实现工具栏
2021-05-10
我用wxPython搭建GUI量化系统之wx.TextCtrl实现文本框
2021-05-10
我用wxPython搭建GUI量化系统之最小架构的运行
2021-05-10
我用wxPython搭建GUI量化系统之Sizer布局管理与页面切换
2021-05-10
我用wxPython搭建GUI量化系统之多只股票走势对比界面
2021-05-10
我用wxPython搭建GUI量化系统之Pandas特性的财务选股工具
2021-05-10
我用wxPython搭建GUI量化系统之财务选股工具添加日历和排序
2021-05-10
搭建量化系统|wxPython布局管理实现多只股票走势对比界面
2021-05-10
2019年达观杯文本智能信息抽取挑战赛 四到十名队伍分享
2021-05-10
一文掌握Python正则表达式
2021-05-10