怎用JavaScript提交表单控制空值?

来源:百度知道 编辑:UC知道 时间:2024/06/06 09:48:32
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<form name="form1" action="t1.asp" method="post" autocomplete="off">
<%mun=15
for i=1 to mun
%>用户名: <input type="text" name="u_name" id="u_name">
<span id="test1">是否能注册</span><br>
<%next%>
<input type="submit" name="submit" value="注册" />
</form>

请仔细看代码..我用了循环.
zicozhang 的办法不行哦. 我是用了一次提交多条数据的

<script language="javascript">
<%mun=15
for i=1 to mun %>
var tmp_name= document.forms[0].u_name[<%= i%>].value;
if (tmp_name==""){
alert("用户名 " + <%= i%> +" 不能为空");
}
<%next%>
</script>

if(form1.u_name.values.length==0)
{
return false;
}

这么控制就行