html部分:
1
2
3
4
5
6
7
8
9
10
11
12
|
<
html
>
<
body
>
<
div
id
=
"bank"
>
输入银行卡:
<
input
size
=
"4"
tabindex
=
"1"
maxlength
=
"4"
onkeyup
=
"checkLen(this,this.value)"
/>
<
input
size
=
"4"
tabindex
=
"2"
maxlength
=
"4"
onkeyup
=
"checkLen(this,this.value)"
/>
<
input
size
=
"4"
tabindex
=
"3"
maxlength
=
"4"
onkeyup
=
"checkLen(this,this.value)"
/>
<
input
size
=
"4"
tabindex
=
"4"
maxlength
=
"4"
onkeyup
=
"checkLen(this,this.value)"
/>
<
input
size
=
"3"
tabindex
=
"5"
maxlength
=
"3"
onkeyup
=
"checkLen(this,this.value)"
/>
</
div
>
</
body
>
</
html
>
|
js部分:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<script type=
"text/javascript"
>
function
checkLen(x,y)
{
if
(y.length==x.maxLength)
{
var
next = x.tabIndex;
if
(next<document.getElementById(
"bank"
).length)
{
document.getElementById(
"bank"
).elements[next].focus();
}
}
}
</script>
|
本文转自 爱笑嘚蛋蛋 51CTO博客,原文链接:http://blog.51cto.com/dd118/1670054,如需转载请自行联系原作者