如何验证这种形式表单中的提交值是否为空?[
时间:2010-05-17
来源:互联网
以下是一销售产品的录入界面,可通过点击“选择产品按钮”后选择商品,设定最大可选20项商品,点击“下一个产品”链接后,又可选择下一项商品,从而实现类似商品明细表增加的操作,下面是代码:
<table align="center" cellpadding="4" cellspacing="1" class="toptable grid" border="1">
<form name="form1" method="post">
<tr>
<td width="10%" align="right" height="30">选择产品:</td>
<td width="90%" class="category">
<table cellpadding="0" cellspacing="0" width="100%" border=0>
<%for x=1 to maxproduit%>
<tr id="cailiaohan<%=x%>"<%if x<>1 then%> style="display:none;"<%end if%>>
<td>
<input name="huohao<%=x%>" readonly onClick="JavaScript:window.open('produit2_back.asp?form=form1&field=huohao<%=x%>&field2=price<%=x%>&field3=hidprice<%=x%>&field4=bianhao<%=x%>&field5=qkjl<%=x%>&field6=jm<%=x%>&field7=guige<%=x%>&field8=zk<%=x%>&field9=sj<%=x%>&field10=xssl<%=x%>&field11=price2<%=x%>&field12=kftel&field13=kfname&field14=selldate1&field15=address&span1=showshulian<%=x%>','','directorys=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=853,height=470,top=176,left=161');" style="width:80px" value="单击选择产品">
销售数量:
<input name="xssl<%=x%>" type="text" id="xxsl<%=x%>" style="width:30px" onKeyUp="value=value.replace(/[^\d.]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))">
退货数量:
<input name="shulian<%=x%>" type="text" id="shulian<%=x%>" style="width:30px" onKeyUp="value=value.replace(/[^\d.]/g,'')" value="0" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))" onPropertyChange="sljc('xssl<%=x%>',this.value,'qkjl<%=x%>','sj<%=x%>')">
<%if x<>maxproduit then%><span onClick="cailiaohan<%=(x+1)%>.style.display=''" style="cursor:hand; ">下一个产品</span><%end if%>
<%if x<>1 then%><input type="button" value="清除" onClick="huohao<%=x%>.value='单击选择产品';shulian<%=x%>.value='1';price<%=x%>.value=''" class="button"><%end if%>
<%if x=1 then%><font color="#ff0000">*</font><%end if%>
<div id="showshulian<%=x%>"></div> </td>
</tr>
<%next%>
</table> </td>
</tr>
<td align="right" height="30">普通客户电话:</td>
<td class="category"><input name="kftel" type="text" id="kftel" style="width:200px"></td>
</tr>
<tr>
<td align="right" height="30">联系地址:</td>
<td class="category"><input name="address" type="text" id="address" style="width:260px"></td>
</tr>
<tr>
<td align="right" height="30"> 销售时间:</td>
<td class="category"><input name="selldate1" type="text" id="selldate1" style="width:200px"></td>
</tr>
<td height="30"> </td>
<td class="category">
<input type="submit" value=" 确认退货 " onClick="return check1()" class="button">
<input type="hidden" name="hid1" value="ok">
<input type="reset" value=" 重新填写 " class="button"> </td>
</tr>
</form>
</table>
在上面的这个表单中,如果使用JS脚本来验证退货数量是否为空,只能验证到第一项记录的值是否为空,如果选择择了第二项产品后,就不能验证了,因为名称为shulian<%=x%>,后面的<%=x%>就是代表从1到20,也就是退货数量为shulian1-shulian20,那如何在表单提交时验证从shulian1-shulian20这些值是否都填写了呢?
[ 本帖最后由 xymc001 于 2010-5-18 20:38 编辑 ]
<table align="center" cellpadding="4" cellspacing="1" class="toptable grid" border="1">
<form name="form1" method="post">
<tr>
<td width="10%" align="right" height="30">选择产品:</td>
<td width="90%" class="category">
<table cellpadding="0" cellspacing="0" width="100%" border=0>
<%for x=1 to maxproduit%>
<tr id="cailiaohan<%=x%>"<%if x<>1 then%> style="display:none;"<%end if%>>
<td>
<input name="huohao<%=x%>" readonly onClick="JavaScript:window.open('produit2_back.asp?form=form1&field=huohao<%=x%>&field2=price<%=x%>&field3=hidprice<%=x%>&field4=bianhao<%=x%>&field5=qkjl<%=x%>&field6=jm<%=x%>&field7=guige<%=x%>&field8=zk<%=x%>&field9=sj<%=x%>&field10=xssl<%=x%>&field11=price2<%=x%>&field12=kftel&field13=kfname&field14=selldate1&field15=address&span1=showshulian<%=x%>','','directorys=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=853,height=470,top=176,left=161');" style="width:80px" value="单击选择产品">
销售数量:
<input name="xssl<%=x%>" type="text" id="xxsl<%=x%>" style="width:30px" onKeyUp="value=value.replace(/[^\d.]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))">
退货数量:
<input name="shulian<%=x%>" type="text" id="shulian<%=x%>" style="width:30px" onKeyUp="value=value.replace(/[^\d.]/g,'')" value="0" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))" onPropertyChange="sljc('xssl<%=x%>',this.value,'qkjl<%=x%>','sj<%=x%>')">
<%if x<>maxproduit then%><span onClick="cailiaohan<%=(x+1)%>.style.display=''" style="cursor:hand; ">下一个产品</span><%end if%>
<%if x<>1 then%><input type="button" value="清除" onClick="huohao<%=x%>.value='单击选择产品';shulian<%=x%>.value='1';price<%=x%>.value=''" class="button"><%end if%>
<%if x=1 then%><font color="#ff0000">*</font><%end if%>
<div id="showshulian<%=x%>"></div> </td>
</tr>
<%next%>
</table> </td>
</tr>
<td align="right" height="30">普通客户电话:</td>
<td class="category"><input name="kftel" type="text" id="kftel" style="width:200px"></td>
</tr>
<tr>
<td align="right" height="30">联系地址:</td>
<td class="category"><input name="address" type="text" id="address" style="width:260px"></td>
</tr>
<tr>
<td align="right" height="30"> 销售时间:</td>
<td class="category"><input name="selldate1" type="text" id="selldate1" style="width:200px"></td>
</tr>
<td height="30"> </td>
<td class="category">
<input type="submit" value=" 确认退货 " onClick="return check1()" class="button">
<input type="hidden" name="hid1" value="ok">
<input type="reset" value=" 重新填写 " class="button"> </td>
</tr>
</form>
</table>
在上面的这个表单中,如果使用JS脚本来验证退货数量是否为空,只能验证到第一项记录的值是否为空,如果选择择了第二项产品后,就不能验证了,因为名称为shulian<%=x%>,后面的<%=x%>就是代表从1到20,也就是退货数量为shulian1-shulian20,那如何在表单提交时验证从shulian1-shulian20这些值是否都填写了呢?
[ 本帖最后由 xymc001 于 2010-5-18 20:38 编辑 ]
作者: xymc001 发布时间: 2010-05-17
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28