Add the following code to the added place OK, 2333
Html
1 <HTML>2 <Head></Head>3 <Body>4 <Divclass= "Pwd-box"ID= "Sixpwd"> 5 <inputtype= "Tel"maxlength= "6"class= "Pwd-input"ID= "Pwd-input" /> 6 <Divclass= "Fake-box"> 7 <inputtype= "Password"ReadOnly="" /> 8 <inputtype= "Password"ReadOnly="" /> 9 <inputtype= "Password"ReadOnly="" /> Ten <inputtype= "Password"ReadOnly="" /> One <inputtype= "Password"ReadOnly="" /> A <inputtype= "Password"ReadOnly="" /> - </Div> - </Div> the </Body> - </HTML>
Css
1 . Pwd-box{2 width:95%;3 Padding-left:1px;4 position:relative;5 Border:1px solid #cdcdcd;6 Border-radius:3px;7 Over-flow:Hidden;8 margin:0 Auto;9 Margin-bottom:1remTen} One A . Pwd-box input[type= "Tel"]{ - width:100%; - Height:48px; the Color:Transparent; - position:Absolute; - Top:0; - Left:0; + Border:0; - font-size:18px; + Opacity:0; A Z-index:1; at letter-spacing:35px -} - - . Fake-box input{ - width:15.111%; - Height:48px; in Border:0; - Border-right:1px solid #cdcdcd; to text-align:Center; + font-size:30px; - Background-color:Transparent the} * $ . Fake-box input:nth-last-child (1){Panax Notoginseng Border:0 -}
Js
1<script>2 var$input = $ (". Fake-box input"); 3$ ("#pwd-input"). On ("Input",function() { 4 varPWD = $ ( This). Val (). Trim (); 5 for(vari = 0, len = pwd.length; i < Len; i++) { 6$input. EQ ("" + i + ""). Val (Pwd[i]); 7 } 8$input. each (function() { 9 varIndex = $ ( This). index (); Ten if(Index >=Len) { One$( This). Val (""); A } - }); - if(len = = 6) { the //perform other actions - } - }); -</script>
Reference 1: Original 1, http://blog.csdn.net/qiuqingpo/article/details/50070183
Reference 2: Pure JS css,http://jsfiddle.net/pj7dvldu/
Input 6-bit password on the phone