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 ...
随机推荐
- 转:客户端session与服务端session
会话(Session)跟踪是Web程序中常用的技术,用来 跟踪用户的整个会话 .常用的会话跟踪技术是Cookie与Session. Cookie通过在客户端记录信息确定用户身份 , Session通过 ...
- c#(控制台应用程序)实现排序算法的研究总结
前言:闲来无事,便研究起来对数组的排序算法,怕过后遗忘,特地总结一下,也希望能帮到大家 概要: 总结的算法: 冒泡排序.插入排序.选择排序 要排序的一列数(从小到大): 1, 5, 3, 83, 4 ...
- awk使用方法与案例介绍
一.awk简介 awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大.简单来说awk就是把文件逐行的读入,以空格为默认分隔符将每行切片,切 ...
- hi3531的时钟系统
时钟管理模块对芯片时钟输入.时钟生成和控制进行统一的管理,包括: 时钟管理模块有以下两部分输入:
- Java之split方法
Java之split方法 1.间隔号"." (1)str.split(".") String str = "10.156.35.87"; S ...
- [Err] 1172 - Result consisted of more than one row
1 错误描述 [Err] 1172 - Result consisted of more than one row Procedure execution failed 1172 - Result c ...
- freemarker自定义标签(三)-nested指令
freemarker自定义标签 1.nested指令 是可选的,可以在<#macro>和</#macro>之间使用在任何位置和任意次数 2.示例说明 <#macro ta ...
- Error Code: 1305. FUNCTION student.rand_string does not exist
1.错误描述 13:52:42 call new_procedure Error Code: 1305. FUNCTION student.rand_string does not exist 0.0 ...
- Linux显示只显示目录文件
Linux显示只显示目录文件 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ ls -l -d */ drwxr-xr-x 2 root root 4096 1 ...
- Android APP开发入门教程-Button
代码编写 做好准备工作后,终于可以开始写我们的hello android了,在开始编写代码之前,我们先了解几个文件: res/layout/main.xml App主窗体布局文件,你的应用长什么样都在 ...