CSS: Create iOS style Pin Password box

后端 未结 6 2306
轮回少年
轮回少年 2021-02-14 03:19

I want to create a html5 input that looks like the iOS enter Pin (on the lock screen).... with 4 input boxes.

How do i achieve this?

6条回答
  •  青春惊慌失措
    2021-02-14 04:04

     
     
     
     
    
    
    $('.display-otp-box').on('keyup', function (e) {
      var key = event.keyCode || event.charCode;
            
      /* for backspace, focus will move to the previous box */ 
      if( key === 8 || key === 46 ){
         $(this).prev('input').focus();
         return;
      }
      $(this).next('input').focus();
     });
    
    • type="tel" on the input will make sure the numeric keypad appears when using on the phone
    • next input will be focused automatically with the help of tabindex.

提交回复
热议问题