input依次输入密码
原理:
一个真正的可以输入的input框,opacity: 0,设定位层级;(视图不可见的)
再来6(n)个input,readyonly,用来显示,type为password,设置好样式;(视图可见的)
代码如下:
<!DOCTYPE html>
<html> <head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>手机端六位密码输入</title>
<script src="http://zeptojs.com/zepto.min.js"></script>
<style>
* {
padding: 0px;
margin: 0px;
} input {
border: none;
outline: none;
background: none;
} #pwd-box {
width: 310px;
height: 48px;
position: relative;
border: 1px solid #9f9fa0;
border-radius: 3px;
overflow: hidden;
margin: 10px auto;
} #pwd-box input[type="number"] {
width: %;
height: %;
color: transparent;
/*letter-spacing 属性增加或减少字符间的空白,字间距*/
letter-spacing: 35px;
position: absolute;
top: ;
left: ;
border: none;
font-size: 18px;
filter: alpha(opacity=);
-moz-opacity: ;
-khtml-opacity: ;
opacity: ;
z-index: ;
outline: none;
} #pwd-box .fake-box {
width: %;
height: %;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row;
-ms-flex-flow: row;
flex-flow: row;
} #pwd-box .fake-box input {
-webkit-box-flex: ;
-webkit-flex: ;
-ms-flex: ;
flex: ;
width: %;
height: %;
border: none;
border-right: 1px solid #e5e5e5;
text-align: center;
font-size: 30px;
float: left;
} #pwd-box .fake-box input:nth-last-child() {
border: none;
}
</style>
</head> <body>
<div id="pwd-box">
<input type="number" maxlength="" class="pwd-input" id="pwd-input" autofocus>
<div class="fake-box">
<input type="password" readonly="">
<input type="password" readonly="">
<input type="password" readonly="">
<input type="password" readonly="">
<input type="password" readonly="">
<input type="password" readonly="">
</div>
</div>
<script>
$("#pwd-input").on("input", function() {
// trim(): 去两边空格的方法;
var pwd = $(this).val().trim();
var len = pwd.length;
for(var i = ; i < len; i++) {
$(".fake-box input").eq(i).val(pwd[i]);
}
$(".fake-box input").each(function() {
var index = $(this).index();
if(index >= len) {
$(this).val("");
}
});
if(len == ) {
//执行其他操作
setTimeout(function() {
alert('订单已提交')
}, ) }
if(len > ) {
pwd = pwd.substr(, );
$(this).val(pwd);
len = ;
}
});
</script>
</body> </html>
input依次输入密码的更多相关文章
- jquery插件--在input下输入密码时提示大写锁定键
//密码大写输入提示 function capitalTip(id){ $('#' + id).after('<div class="capslock" id="c ...
- Python初体验(一)—【配置环境变量】【变量】【input】【条件语句】【循环语句】
写在前面的: 作为一个控制专业的女研究生,不知道每天在研究什么,但总归逃脱不了码代码的命运.之前也学习过一些C语言.C++,基础嘛,稍稍微有一些.本不想走上码农的道路,天真烂漫的过此生(白日梦过程中. ...
- (13)input输入函数
(1)input 等待用户动态输入一个值,注意得到的值是一个字符串类型 提示用户输入用户名和密码: 如果用户名是admin , 并且密码是000 , 提示用户恭喜你,登陆成功 否则提示用户名或密码错误 ...
- input用法,永远等待,直到用户输入值赋值给一个东西。
input用法,永远等待,直到用户输入值赋值给一个东西. n1 = input('请输入用户名:') n1 = input('请输入密码:') print(n1) print(n1)
- python常用执行方式&变量&input函数
linux系统中执行py文件方式: ./a.py 需要执行权限 chmod -R 777(最大权限) 常用执行方式: 1. ./a.py2. python a.py 文件内部头加上 #!/usr/b ...
- 2018年11月10日 input,print,pass 用法,条件语句+字符串
name=input('请输入用户名')#永远等待用户输入 password=input('请输入密码') print(name) print(password) 变量定义的规则: 变量名只能是 字母 ...
- python基础知识input到while循环
j周笔记 输入与输出 1.输入 input ('请输入内容')= 字符串 2.输出 print(输出到控制台) 变量vairable 变量就是相当于我们人的名字 1.名字 ...
- 常量、变量;基本数据类型;input()、if、while、break、continue
一.编译型语言和解释型语言区别:编译型:一次性将所有程序编译成二进制文件 缺点:开发效率低,不能跨平台 优点:运行速度快. 例如:C,C++等解释型:当程序执行时,一行一行的解释 优点:开发效率高,可 ...
- 180908 input
input while if # -*- coding:utf-8 -*- flag = 0 while flag == 0 : username = input('请输入用户名:\n') passw ...
随机推荐
- 第二十一章 Django的分页与cookie
第二十一章 Django的分页与cookie 第一课 模板 1.模板的继承 在Template目录下新建模板master.html <!DOCTYPE html> <html lan ...
- 计蒜客 无脑博士 bfs
题目链接无脑博士的试管们 思路:直接模拟倒水过程即可,但是需要记忆判断当前的情况是否已经处理过.dfs和bfs都ok AC代码 #include <cstdio> #include < ...
- UVA-804 模拟
将每个translation的输入和输出place全部记录下来,模拟即可,当所有translation都不能工作时,就说明dead了. AC代码: #include<cstdio> #in ...
- eclipse web and java ee development
1.打开Eclipse ->help ->install new software 2.Work with:http://download.eclipse.org/releases/gan ...
- javascript-深入理解&&和||
先从两个问题看起: 第一个问题 为什么 a && b 返回的是true,b && a 返回的是6 var user = 6; var both = true; cons ...
- 嵌入式Linux引导过程之1.5——从BootRom到Xloader
在开始看Xloader_Entry的代码之前,我想先总结一下从芯片上电到开始运行Xloader的代码的过程,这是我目前理解的一个过程,可能有所出入,待以后继续完善. 当 系统上电之后,首先会将PC寄存 ...
- CBitmap的使用
MFC提供了位图处理的基础类CBitmap,可以完成位图(bmp图像)的创建.图像数据的获取等功能.虽然功能比较少,但是在对位图进行一些简单的处理时,CBitmap类还是可以胜任的.很多人可能会采用一 ...
- 在windows XP系统下编译和使用ffmpeg
最近在做流媒体开发这一块,在服务器端,所用的live555不支持mp4,avi等视频容器格式,所以打算运用ffmpeg来进行扩展.将MP4文件先运用ffmpeg进行解析,解析成live555所支持的基 ...
- DirectDraw用到的DDSURFACEDESC2
DDSURFACEDESC2 结构定义一个需求的平面.下面的例子演示了结构的定义和标志位的设定: // Create the primary surface with one back buffer. ...
- FusionCharts封装-Category
Categories.java: /** * @Title:Categories.java * @Package:com.fusionchart.model * @Description:Fusion ...