日期:2014-05-17  浏览次数:20690 次

ASP文本框的宽度
我想实现这个功能:在ASP中,可以限定文本框只能输入数字,并且数字的位数也可以事先设定。现在有个问题:输入内容的时候,当达到指定宽度的时候,光标仍然停在文本框内。
我现在想,当达到设定的宽度的时候,光标自动移出该文本框,就像按下TAB键一样!

------解决方案--------------------
<html>
<head>

</head>
<script>
function checkLength(){
var txt1=document.getElementById( "txt1 ");
var txt2=document.getElementById( "txt2 ");
if(txt1.value){
if(txt1.value.length==6)txt2.focus();
}
}
</script>
<body >
*限制字符6位,到6位时下面的文本框获得焦点 <br> ** <input type= "text " id "txt1 " name= "txt1 " onpropertychange= "checkLength() "> <br>
*** <input type= "text " id "txt2 " name= "txt2 "> <br>
</body>
</html>
onpropertychange事件仅限IE
跨浏览器支持方法参见贴子:http://community.csdn.net/Expert/topic/5524/5524226.xml?temp=.836117