当前位置:网站首页>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 .
边栏推荐
- Difference between asemi high power FET and triode
- Method of opening data recovery of solid state disk
- A summary of the experiment of continue and break in C language
- 渗透测试-目录遍历漏洞
- Opensea PHP development kit
- Response (XI)
- Attack and defense world web baby Web
- 本轮压力测试下,DeFi协议们表现如何?
- Object creation and invocation code example
- Personalized Federated Learning with Moreau Envelopes
猜你喜欢

魔法猪系统重装大师怎么使用

What is Ethernet and how to connect the computer

IronOCR 2022.1 Crack

TeeChart Pro ActiveX 2022.1

Route parameters to jump to the page and transfer parameters -- > hidden parameter list

渗透测试-提权专题

两小时带你进入软件测试行业风口(附全套软件测试学习路线)

CSRF (Cross Site Request Forgery) &ssrf (server request forgery) (IV)

What if the desktop computer is not connected to WiFi

dotnet-exec 0.4.0 released
随机推荐
Laravel Vonage SMS sending
How to use the Magic pig system reinstallation master
MySQL concept and operation (III)
ORA-00800: soft external error
渗透测试-提权专题
Array: force deduction dichotomy
Basic knowledge of web pages (URL related)
Personalized Federated Learning with Moreau Envelopes
Use js to simply implement the apply, call and bind methods
Drag modal box
parallel recovery slave next change & parallel recovery push change
固態硬盤開盤數據恢複的方法
融合CDN,为客户打造极致服务体验!
How to install the blue lake plug-in to support Photoshop CC 2017
Matlab notes
How do the defi protocols perform under this round of stress test?
Kotlin compose listens to the soft keyboard and clicks enter to submit the event
buuctf(pwn)
【图像融合】基于matlab方向离散余弦变换和主成分分析图像融合【含Matlab源码 1907期】
parallel recovery slave next change & parallel recovery push change