87,910
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
<script>
//如果长度大于等于4,则切换焦点
function proChange(o){
if(o.value.length>=4){
do{
o = o.nextSibling;
}while(o!=null&&o.tagName!='INPUT');
if(o!=null){
o.focus();
}
}
}
</script>
</head>
<body>
<input type="text" onpropertychange="proChange(this)" value=""/>
<input type="text" onpropertychange="proChange(this)" value=""/>
<input type="text" onpropertychange="proChange(this)" value=""/>
<input type="text" onpropertychange="proChange(this)" value=""/>
<br>
<input type="text" onpropertychange="proChange(this)" value=""/>
<input type="text" onpropertychange="proChange(this)" value=""/>
<input type="text" onpropertychange="proChange(this)" value=""/>
<input type="text" onpropertychange="proChange(this)" value=""/>
<br>
<input type="text" onpropertychange="proChange(this)" value=""/>
<input type="text" onpropertychange="proChange(this)" value=""/>
<input type="text" onpropertychange="proChange(this)" value=""/>
<input type="text" onpropertychange="proChange(this)" maxlength=4 value=""/>
</body>
</html>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试</title>
<style>
</style>
<script src="jquery-1.3.2.js"></script>
<script>
$(function(){
$(".input").keyup(function(){
var value = $(this).val();
if(value.length>=5){//最多填五个字符
$(this).next().focus();
}
});
});
</script>
</head>
<body>
<input type="text" id="input1" class="input" />
<input type="text" id="input2" class="input" />
<input type="text" id="input3" class="input" />
</body>
</html>