获取焦点 想实现一个功能有两个输入框,在第一个输入框输入手机号码输入完后(一定是要输入完11位),第2个框自动获得焦点,请问该怎样实现 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script language="javascript"> function pd(){ if(document.f1.txt1.value.length != 11){ alert("不等于11位"); document.f1.txt1.focus(); }else{ document.f1.txt2.focus(); }} </script><form name="f1"><input type="text" name="txt1" onBlur="pd()" /><input type="text" name="txt2" /></form> <input type="text" id="txt1" onkeyup="chklength()" maxlength=11/><input type="text" id="txt2" /><script language="javascript">function chklength(){ if (txt1.value.length==11) {txt2.focus(); txt2.select();}} </script> if (txt1.value.length==11) {txt2.focus(); txt2.select();} <input type="text" id="txt1" onkeyup="AutoNext(this.value)" maxlength=11/><input type="text" id="txt2" /><script language="javascript">function AutoNext(s){ if (s.length==11) {txt2.focus(); txt2.select();}} </script> <html> <head> <title>自动获取焦点</title> </head> <body> <input name="key" type="text" id="key" onFocus="clearq()"><input name="2N" type="text" id="asdda" OnKeyPress="getID()"><script> function getID(){ var valueID=document.getElementById("asdda").value; if(valueID.length>=11){ document.getElementById("key").focus(); } }function clearq(){ document.getElementById("key").value="";}</script></body> </html> 参考一下,基本能实现! C#代码:void Form1_textBox1_TextChanged(object sender, System.EventArgs e) { if (textBox1.Text.Length == 11) { textBox2.Focus(); } } js 的对象几时销毁 style.display属性 监视页面事件 有没有办法在另一个页面插入代码 javascript问题,解决马上给分 jsp如何得到当前页面里javascript的值 <div>如何加滚动条? 一个网页中两个SELECT,怎麽让点SELECT1的某项,在SELECT2中显示动态从数据库或folder中读出内容 各位好心人,说说怎么办??? 用js做了一个cookie显示用户访问记录,火狐显示没问题,ie显示异常 关于<a>中href的写法 JavaScript正则去除HTML部分标签
function pd(){
if(document.f1.txt1.value.length != 11){
alert("不等于11位");
document.f1.txt1.focus();
}else{
document.f1.txt2.focus();
}
}
</script>
<form name="f1">
<input type="text" name="txt1" onBlur="pd()" />
<input type="text" name="txt2" />
</form>
<input type="text" id="txt1" onkeyup="chklength()" maxlength=11/>
<input type="text" id="txt2" />
<script language="javascript">
function chklength(){
if (txt1.value.length==11) {txt2.focus(); txt2.select();}
}
</script>
<input type="text" id="txt1" onkeyup="AutoNext(this.value)" maxlength=11/>
<input type="text" id="txt2" />
<script language="javascript">
function AutoNext(s){
if (s.length==11) {txt2.focus(); txt2.select();}
}
</script>
<head>
<title>自动获取焦点</title>
</head>
<body> <input name="key" type="text" id="key" onFocus="clearq()">
<input name="2N" type="text" id="asdda" OnKeyPress="getID()">
<script>
function getID(){
var valueID=document.getElementById("asdda").value;
if(valueID.length>=11){
document.getElementById("key").focus();
}
}
function clearq(){
document.getElementById("key").value="";
}
</script></body>
</html>
参考一下,基本能实现!
void Form1_textBox1_TextChanged(object sender, System.EventArgs e)
{
if (textBox1.Text.Length == 11)
{
textBox2.Focus();
}
}