一个得分的好机会,马上给分!!

qiao198 2003-05-29 06:27:33
我的文本框很多,如T1,T2,T3,T4.现在我要用JS来循环判断它是否为空,
请各位帮帮我,怎么来搞定。OK
...全文
77 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
denghan 2003-05-29
  • 打赏
  • 举报
回复
<html>
<head>
<title>上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
var UpTure=false;
var FilePath="upload.asp?fid=<%=rndInt%>";
function setid()
{ str='<br>';
if(!window.form1.upcount.value)
window.form1.upcount.value=1;
else
if (window.form1.upcount.value > 5)
{ alert("抱歉,最多只能同时上传5个文件");
window.form1.upcount.value=5;
return false;
}
for(i=1;i<=window.form1.upcount.value;i++)
str+='文件'+i+':<input type="file" name="file'+i+'" style="width:400" class="tx1"><br><br>';
window.upid.innerHTML=str+'<br>';
}
function check()
{var upno=0;
var info="";
var dengflag=0;
for(i=1;i<=window.form1.upcount.value;i++)
{eval("var ncd=document.form1.file"+i+".value;");
if (ncd=="")
{
info+=" 第" + i + " 个框为空!\n"; dengflag=1;
dengflag = 1;
}
}
if (dengflag)
{
alert(info);
return false;
}
else
{
var fpath=document.form1.filepath.value;
if (!flag) return false;
fpath=FilePath+"&filepath="+document.form1.filepath.value;
document.form1.action=fpath;
return true;
}
}
//取文件名函数
function findname(vl)
{var no0=vl.lastIndexOf("\\");
var no1=vl.lastIndexOf(".");
var no2=vl.indexOf(":");
if (no0==-1 || no1==-1 || no2!=1 || no0>no1) return ;
var fname=vl.substr(no0+1);
return fname;
}
//取扩展名函数
function extname(v1)
{ var no0=v1.lastIndexOf(".");
var no1=v1.substr(no0+1,v1.length-no0);
return no1;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" oncontextmenu=self.event.returnValue=false >
<form name="form1" method="post" action="upload.asp" enctype="multipart/form-data" onsubmit="return check()">
<br>
<input type="hidden" name="act" value="upload">
<br>
<table width="542" border="1" cellspacing="0" cellpadding="5" bordercolordark="#CCCCCC" bordercolorlight="#000000">
<tr bgcolor="#CCCCCC">
<td height="22" align="left" valign="middle" bgcolor="#CCCCCC" width="540">欢迎您,<%=username%>
</td>
</tr>
<tr align="left" valign="middle" bgcolor="#eeeeee">
<td bgcolor="#eeeeee" height="92" width="540">
<li> 需要上传的文件个数
<input type="text" name="upcount" class="tx" value="1" onchange="setid();">
</li>

</td>
</tr>
<tr align="center" valign="middle">
<td align="center" height="22" width="540"> </td>
</tr>
<tr align="center" valign="middle">
<td align="left" id="upid" height="122" width="540"> 文件1:
<input type="file" name="file1" style="width:400" class="tx1" value="">
</td>
</tr>
<tr align="center" valign="middle" bgcolor="#eeeeee">
<td bgcolor="#eeeeee" height="24" width="540">
<input type="submit" name="Submit" value="· 提交 ·" class="bt">
<input type="reset" name="Submit2" value="· 重执 ·" class="bt" onclick="setTimeout('setid();',100);">
</td>
</tr>
</table>
</form>
<script language="javascript">
//setid();
//if (UpTrue) {document.form1.Submit.disabled=0;}
</script>
</body>
</html>
nchen123 2003-05-29
  • 打赏
  • 举报
回复
向tdl982324(石井坚) 同志学习。
lsrzm 2003-05-29
  • 打赏
  • 举报
回复
名字写错了
<form name = form1>
<input type=text name = t >
<input type=text name = t >
<input type=text name = t >
<input type=button value=check onclick="checkText()">
</form>
<script>
function checkText()
{
for (i = 0 ;i<form1.t.length;i++)
{
if (form1.t[i].value=="")
{
alert("not");
form1.t[i].focus();
return false;
}
}

}
</script>
lsrzm 2003-05-29
  • 打赏
  • 举报
回复
<form name = form1>
<input type=text name = t >
<input type=text name = t >
<input type=text name = t >
<input type=button value=check onclick="checkText()">
</form>
<script>
function checkText()
{
for (i = 0 ;i<form1.t1.length;i++)
{
if (form1.t1[i].value=="")
{
alert("not");
return false;
}
}

}
</script>
Reker熊 2003-05-29
  • 打赏
  • 举报
回复
<script>
function checkText()
{
var txtArray=document.getElementsByTagName("input");
for (i=0;i<txtArray.length;i++)
{if ((txtArray[i].type=="text")&&(txtArray[i].value==""))
{alert("the "+(i+1).toString()+"th text is null");}
}
}
</script>
<input type=text>
<input type=text>
<input type=text>
<input type=button value=check onclick="checkText()">

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧