当前位置:网站首页>JS verification code input number auto skip
JS verification code input number auto skip
2022-06-25 05:06:00 【Lijianyi】
Use Js Auto skip for verification code input
HTML part :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="css/index.css" />
<script src="js/jquery-3.4.1.min.js"></script>
</head>
<body>
<div>
<input type="text" maxlength="1" class="inputNumber" />
<input type="text" maxlength="1" class="inputNumber" />
<input type="text" maxlength="1" class="inputNumber" />
<input type="text" maxlength="1" class="inputNumber" />
</div>
<script src="js/index.js"></script>
</body>
</html>
Js part :
$(function(){
let inputNumber = $(".inputNumber");
inputNumber.focus(function(event){
inputNumber.keyup(function(event){
// console.log(event.which);
switch(event.which){
case 39:
console.log(" towards the right ");
$(this).next().focus();
break;
case 37:
console.log(" towards the left ");
$(this).prev().focus();
break;
case 8:
console.log(" Delete ");
$(this).prev().focus();
break;
default:
let valueNumber = $(this).val();
if(valueNumber === "" || valueNumber == null){
return false;
}
if(!isNaN(valueNumber)){
$(this).next().focus();
}else{
alert(" Not numbers ");
$(this).val("");
}
}
})
})
})
here CSS The code is not pasted , If you need to do it yourself .
principle :
When input Input box gets focus , And when the keyboard key is lifted , Trigger method , Mainly to obtain : Left key 、 Press the right key 、backspace Key 、 Number buttons .
This process changes the focus of the input field .
边栏推荐
- Abuse unlimited authorization -- is your address safe?
- Triangle class (construction and deconstruction)
- 固態硬盤開盤數據恢複的方法
- Small sample learning data set
- Virtual honeypot Honeyd installation and deployment
- 两小时带你进入软件测试行业风口(附全套软件测试学习路线)
- Swift rapid development
- In depth understanding of line height and vertical align
- Summary of SQL injection (I)
- 投资理财产品的年限要如何选?
猜你喜欢
[image fusion] image fusion based on MATLAB directional discrete cosine transform and principal component analysis [including Matlab source code 1907]
XSS (cross site script attack) summary (II)
buuctf web
Ranorex Studio 10.1 Crack
buuctf(pwn)
Student achievement management system based on SSH
Customize the console plot result style
SOC验证环境的启动方式
固態硬盤開盤數據恢複的方法
ASEMI大功率场效应管和三极管的区别
随机推荐
MySQL concept and operation (III)
The print area becomes smaller after epplus copies the template
Abuse unlimited authorization -- is your address safe?
Compatible with Internet Explorer
[image fusion] image fusion based on MATLAB directional discrete cosine transform and principal component analysis [including Matlab source code 1907]
Prototypical Networks for Few-shot Learning
投资理财产品的年限要如何选?
Detailed summary of float
Precise delay based on Cortex-M3 and M4 (systick delay of system timer can be used for STM32, aducm4050, etc.)
IronOCR 2022.1 Crack
以太网是什么要怎么连接电脑
ThinkPHP 5 log management
基于SSH实现的学生成绩管理系统
Fun CMD command line~
Mobile number regular expression input box loses focus verification
Matlab notes
Penetration information collection steps (simplified version)
EL & JSTL (XIII)
OLAP analysis engine kylin4.0
Create an environment for new projects