Input 6-bit password on the phone

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.