1

在当前屏幕中,我想使用 javascript 进行验证

1.用户不能在RO Qty中输入负值。和

2.RO 数量值应小于发货数量。

对于第一次验证,我编写了 javascript 并在 button 的 keypress 事件中调用它。

  function onlyNumeric() {

        if (event.keyCode < 48 || event.keyCode > 57) {
            alert("Invalid RoQuantity,Quantity should not be negative.");
            event.returnValue = false;
        }
    }

它工作正常,但是当我想在 keyup 和 keydown 中添加更小和更大的验证时,负值验证不起作用。

对于第二次验证,我尝试过这样但没有成功

if (document.getElementById("ROQuantity").value > document.getElementById("shpdqty").innerHTML) {
            alert("Please Enter RO Qty, and ROQty shouldnot be greater then shipped quantity.");
            return false;
        }

这也适用,但仅适用于第一行,因此如何在此处使用 for 循环,以便它适用于所有行。

所以请帮我怎么做。

还有一件事是 ASP CLASSIC 页面。

这是我绑定值的 TR 标签。

<tr valign="top" bgcolor="#E9E9E9">
      <td colspan="2" bgcolor="#FFFFFF" scope="col">
        <table width="100%" border="0" cellpadding="10" cellspacing="0" bordercolor="#E5E5E5"
                                        id="ctl00_ContentPlaceHolder1_GV">
            <tr bgcolor="#333333">
               <td scope="col">
                 <strong><font color="#FFFFFF">No</font></strong>
                </td>
                <td align="center" scope="col">
                  <strong><font color="#FFFFFF">Carton</font></strong>
                </td>
                <td scope="col">
                   <strong><font color="#FFFFFF">Article Code </font></strong>
                </td>
                <td align="center" scope="col">
                   <strong><font color="#FFFFFF">Color</font></strong>
                 </td>
                <td align="center" scope="col">
                   <strong><font color="#FFFFFF">Size</font></strong>
                </td>
                <td align="right" scope="col">
                   <strong><font color="#FFFFFF">Order Qty</font></strong>
                </td>
                <td align="center" scope="col">
                   <strong><font color="#FFFFFF">Shipped Qty </font></strong>
                </td>
                <td align="center" scope="col">
                   <strong><font color="#FFFFFF">RO Qty</font></strong>
                </td>
              </tr>
            <tbody>

         <% i =1
            set rs1 = server.CreateObject("adodb.recordset")
            sql1 = "SELECT     tblOrderAllocationListItems.OItemID, tblOrderAllocationListItems.MALItemID, tblOrderAllocationListItems.OrderNo, " & _
                    "tblOrderAllocationListItems.MALNo, tblOrderAllocationListItems.CartonName, tblOrderAllocationListItems.ArticleCode, " & _
                    "tblOrderAllocationListItems.Cup, tblOrderAllocationListItems.ColorID, " & _ 
                    "tblOrderAllocationListItems.SizeID, tblOrderAllocationListItems.UOM, tblOrderAllocationListItems.ArticleCostPrice, " & _
                    "tblOrderAllocationListItems.ArticleRCP, tblOrderAllocationListItems.OrderedQuantity, tblOrderAllocationListItems.ShippedQuantity, tblOrderAllocationListItems.ROQuantity, " & _
                    "tblArticleImage.ImagePath FROM tblOrderAllocationListItems LEFT OUTER JOIN " & _
                    "tblArticleImage ON tblOrderAllocationListItems.ArticleCode = tblArticleImage.ArticleCode where tblOrderAllocationListItems.OrderNo = '" & OrderNo & "' order by tblOrderAllocationListItems.CartonName, tblOrderAllocationListItems.ArticleCode"   
            rs1.Open sql1,strconnect,3,3,&H0001
            while Not rs1.EOF

            if i mod 2 = 0 then
            nbgcolor = "#F3F3F3"
            else
            nbgcolor = "#FFFFFF"
            end if

            orderamt = rs1("OrderedQuantity") * rs1("ArticleCostPrice")
            shippedamt = rs1("ShippedQuantity") * rs1("ArticleCostPrice")
            ShippedVarious = rs1("OrderedQuantity") - rs1("ShippedQuantity") 
            ROamt = rs1("ROQuantity") * rs1("ArticleCostPrice")
                                        %>
                                        <tr bgcolor="<%=nbgcolor%>">
                                            <td>
                                                <%=i%>
                                            </td>
                                            <td align="center">
                                                <font color="#000000">
                                                    <%=rs1("CartonName")%>
                                                </font>
                                            </td>
                                            <td>
                                                <a href="javascript:popup('http://www.anakku.com/v5/products_detail.asp?pro_id=609','photo','scrollbars=yes,resizable=yes,width=400,height=400')">
                                                    <font color="#000000">
                                                        <%=rs1("ArticleCode")%>
                                                    </font></a>
                                            </td>
                                            <td align="center">
                                                <a href="javascript:popup('http://www.anakku.com/v5/products_detail.asp?pro_id=609','photo','scrollbars=yes,resizable=yes,width=400,height=400')">
                                                    <font color="#000000">
                                                        <%=rs1("ColorID")%>
                                                    </font></a>
                                            </td>
                                            <td align="center">
                                                <font color="#000000">
                                                    <%=rs1("SizeID") & "/" & rs1("Cup")%>
                                                </font>
                                            </td>
                                            <td align="right" bgcolor="#D9D9FF">
                                                <font color="#000000">
                                                    <%=rs1("OrderedQuantity")%>
                                                </font>
                                            </td>

//我想比较这两个TD

               <td align="center" bgcolor="#C6FFC6" id="shpdqty">
                     <%=rs1("ShippedQuantity")%>
                </td>
               <td align="center" bgcolor="#D5E6FF">
                  <input name="ROQuantity<%=rs1("OItemID")%>" type="text" value="<%=rs1("ROQuantity")%>"
                                                    id="ROQuantity" size="5" onkeypress="onlyNumeric();" />
                                            </td>

                                        </tr>
                                        <%
            tOrderedQuantity = tOrderedQuantity + rs1("OrderedQuantity")                
            tShippedQuantity = tShippedQuantity + rs1("ShippedQuantity")                
            tShippedvariousQuantity = tShippedvariousQuantity + ShippedVarious              
            tROQuantity = tROQuantity + rs1("ROQuantity")
            tROamt = tROamt + ROamt

            i = i + 1
            rs1.movenext
            wend
            rs1.close
            set rs1 = nothing                   
                                        %>
                                        <tr style="color: #333333; background-color: white">
                                            <td colspan="5" align="right">
                                                <strong>Total Qty</strong>
                                            </td>
                                            <td align="right" bgcolor="#AEAEFF">
                                                <strong>
                                                    <%=tOrderedQuantity%>
                                                </strong>
                                            </td>
                                            <td align="center" bgcolor="#AAFFAA">
                                                <strong>
                                                    <%=tShippedQuantity%>
                                                </strong>
                                            </td>
                                            <td align="center" bgcolor="#AEAEFF">
                                                <font color="#000000">
                                                    <%=tROQuantity%>
                                                </font>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
4

1 回答 1

0

将其更改为:

if (parseInt(document.getElementById("ROQuantity").value) > parseInt(document.getElementById("shpdqty").innerHTML)) {
于 2012-10-02T07:22:32.363 回答