In the current screen I want to do a validation using javascript
1.User should not enter the negative value in RO Qty. and
2.The RO Qty value should be less than shipped qty.
For first validation I written the javascript and called its in keypress
event of button .
function onlyNumeric() {
if (event.keyCode < 48 || event.keyCode > 57) {
alert("Invalid RoQuantity,Quantity should not be negative.");
event.returnValue = false;
}
}
Its working fine but when I want to add the validation for smaller and
greater in keyup and keydown then negative value validation is not working.
For 2nd validation I tried like this but not sucessfull
if (document.getElementById("ROQuantity").value > document.getElementById("shpdqty").innerHTML) {
alert("Please Enter RO Qty, and ROQty shouldnot be greater then shipped quantity.");
return false;
}
This is also working but only for first row , so how to use for loop here so it will
work for all rows.
So please help me how to do it.
And one more thing this is ASP CLASSIC page.
This the TR tag where i am binding the value.
<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>
//I WANT TO COMPARE THESE TWO 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>
Change it to: