现有input n个,id分别为a,b,c,d...
如果不限制就可以随意输入,但现要求
排在前面的必须先输入,函数该怎么写比较好。
如果不限制就可以随意输入,但现要求
排在前面的必须先输入,函数该怎么写比较好。
解决方案 »
- 求一个js的代码用于输出换行
- js实现删除后关闭对话框
- |zyciis| 200分求:ymPrompt.js提示控件,无法放在Form中,但我一定要放在Form中;IE出错提示:无法打开 Internet 站点 在线 急
- 求一正则表达式,
- 如何将字符串转成对象?
- 如何在javascript或vbscript里调用有多个形参的activex控件方法
- 关于在asp.net mvc中使用CKEditor的问题
- 急!!!!!!!如何让在<div>内容</div>中的内容不换行!!!!!!!
- TO:net_lover(孟子E章).
- jquery uploadify插件 问题
- js 菜单问题
- DIV显示和隐藏的问题
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload=function(){TBox=document.getElementsByTagName("input")}//获取input集合
function aa(obj)
{
for(i=0;i<TBox.length;i++ )//循环每一个input
{
if(TBox[i].id==obj.id)//取得当前鼠标选中项
{
if(i!=0)//不是第一项
{
if(TBox[i-1].value=="")//检查鼠标选中项的上面一项是否为空
{
aa(TBox[i-1])//去检查鼠标选中项的上面的一项 重复执行
}
else
{
TBox[i].onfocus="";//检查鼠标选中项的上面一项不为空 清空focus
TBox[i].focus();//检查鼠标选中项的上面一项不为空 选中input获取焦点
}
}
else
{
TBox[0].focus();//是第一项就要获取焦点
}
}
}
}
</script>
</head><body>
<form id="form1" name="form1" method="post" action="">
<p>
<input type="text" name="a" id="a" />
</p>
<p>
<input type="text" name="b" id="b" onfocus="aa(this)" />
</p>
<p>
<input type="text" name="c" id="c" onfocus="aa(this)"/>
</p>
<p>
<input type="text" name="e" id="e" onfocus="aa(this)" />
</p>
<p>
<input type="text" name="f" id="f" onfocus="aa(this)"/>
</p>
<p>
<input type="text" name="g" id="g" onfocus="aa(this)" />
</p>
<p>
<input type="text" name="h" id="h" onfocus="aa(this)"/>
</p></p>
</form>
</body>
</html>
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title>无标题文档 </title>
<style></style>
<script>
function change(){
var ia = document.getElementById("a");
var ib = document.getElementById("b");
var ic = document.getElementById("c");
var id = document.getElementById("d");
if(ia.value==""){
ib.disabled = 'disable';
}else{
ib.disabled = '';
}
if(ib.value==""){
ic.disabled = 'disable';
}else{
ic.disabled = '';
}
if(ic.value==""){
id.disabled = 'disable';
}else{
id.disabled = '';
}
}
</script>
</head>
<body>
<input type="text" id="a" onkeyup="change()" /><br />
<input type="text" id="b" onkeyup="change()" disabled="disabled" /><br />
<input type="text" id="c" onkeyup="change()" disabled="disabled" /><br />
<input type="text" id="d" disabled="disabled" /><br />
</body>
</html>
<script>
function chk(id){
num=id.match(/\d+/g)
if(num==1){return;} var preID='a'+(num-1);
var o=document.getElementById(preID);
if(o.value.length==0){
alert("请先填写上一个输入框!");o.focus();
}
}
</script>
<input type="text" name="a" id="a1" onkeydown='chk(this.id);'><br>
<input type="text" name="b" id="a2" onkeydown='chk(this.id);'><br>
<input type="text" name="c" id="a3" onkeydown='chk(this.id);'><br>
<input type="text" name="d" id="a4" onkeydown='chk(this.id);'><br>