有四个文本框,用什么方法可以在输入完一个文本框以光标自动跳到下一个文本框?每个文本框的输入长度都是有限制的~
解决方案 »
- IE与其他浏览器处理结果不同
- 问下request.setCharacterEncoding()、response.setCharacterEncoding()的区别是什么?
- linux中发布怎么web应用?
- 如何在servlet里面得到select框的所有值?(在线等!)
- 老问题,关于读数据库的汉字数据在浏览器上显示问号的问题
- jquery $.ajax $.get $.post的区别是什么噢?
- java web中监听器实现在线用户列表
- JSP如何实现多人在线聊天
- 【求围观,求指点】Spring MVC 项目构建
- 请问一个oracle resultset的问题
- ssh简单问题:调用NewsDAO里面操作数据库的方法出错
- 请教一下关于 RequestDispatcher 这个方法的一个小问题
//正解,键盘按下或抬起事件,判断输入的长度,如果长度够了,下个输入框.focus()
是这样吗?
具体的怎么实现??
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<table>
<tr>
<td><input name="text1" type="text" style="maxlength:8" onkeydown="check(this)"></td>
</tr>
<tr>
<td><input name="text2" type="text" style="maxlength:8" onkeydown="check(this)"></td>
</tr>
<tr>
<td><input name="text3" type="text" style="maxlength:8" onkeydown="check(this)"></td>
</tr>
<tr>
<td><input name="text4" type="text" style="maxlength:8" onkeydown="check(this)"></td>
</tr>
</table>
</body>
</html>
<script language="javascript">
function check(obj){
var max=obj.style.maxlength;
if(obj.value.length>=max){
event.keyCode=9;
}
}
</script>拿去使用吧
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档 </title><script language="javascript">
function check(txt,evt)
{
var key = (window.Event)?evt.which:evt.keyCode;
if(key==13){
with(document.myfrm){
if(txt=="text1"){
if(text1.value.length>2){
text2.focus();
text2.select();
}
}
if(txt=="text2"){
text3.focus();
}
}
}
}
</script>
</head><body>
<form name="myfrm">
<table>
<tr>
<td> <input name="text1" type="text" style="maxlength:8" onkeypress="check('text1',event)"> </td>
</tr>
<tr>
<td> <input name="text2" type="text" style="maxlength:8" onkeypress="check('text2',event)"> </td>
</tr>
<tr>
<td> <input name="text3" type="text" style="maxlength:8" onkeypress="check('text3',event)"> </td>
</tr>
<tr>
<td> <input name="text4" type="text" style="maxlength:8" onkeypress="check('text4',event)"> </td>
</tr>
</table>
</form>
</body>
</html>