This article describes the JS implementation of more than the length limit automatically jump to the next text box method. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>js control exceeds the length limit automatically jumps to the next text box </title>
<body>
<input type= "text" size= "ten" >
<input type= "text" size= "ten" >
<input type= "text" size= "ten" >
<script language= "JavaScript" >
function each (ARR,FN) {for (Var i=0,len=arr.length;i<len;i++) {Fn.call (Arr[i],i,arr);};
(function (inputs) {
Each (inputs,function (i) {
var _o=this;
This.onkeyup=function () {
if (_o.value.length>=4) {
if (Inputs[i+1]) {
Inputs[i+1].focus ();
}else{
_o.value=_o.value.slice (0,4);
}
}
}
})
}) (document.getElementsByTagName (' input '));
</script>
</body>
I hope this article will help you with your JavaScript programming.