| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 666 人关注过本帖
标题:如何验证这种形式表单中的提交值是否为空?[
只看楼主 加入收藏
xymc001
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-3-19
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
如何验证这种形式表单中的提交值是否为空?[
以下是一销售产品的录入界面,可通过点击“选择产品按钮”后选择商品,设定最大可选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">&nbsp;</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这些值是否都填写了呢?
搜索更多相关主题的帖子: 表单 形式 验证 
2010-05-17 09:41
gupiao175
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:40
帖 子:1787
专家分:7527
注 册:2007-6-27
收藏
得分:20 
JS是客户端的东西,而〈%形式的是服务端的,2个不是同一个环境,要用JS去判断所有输出的情况,好象是无法做到的!
退货数量是从服务端数据库里取得的数据?自动输出退货数量,还需要判断其是否为空??


Q:1428196631,百度:开发地 即可找到我,有事请留言!
2010-05-18 19:09
快速回复:如何验证这种形式表单中的提交值是否为空?[
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012546 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved