JS automatically redirects to the next text box after the length limit is exceeded. js automatically redirects
This article describes how to automatically jump to the next text box after JS has exceeded the length limit. Share it with you for your reference. The specific implementation method is as follows:
Copy codeThe Code is as follows: <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> automatically jump to the next text box after JS control exceeds the length limit </title>
</Head>
<Body>
<Input type = "text" size = "10">
<Input type = "text" size = "10">
<Input type = "text" size = "10">
<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>
</Html>
I hope this article will help you design javascript programs.