Thank you Jason.
I've getting a syntax error with that...
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/springparknursery/plant-information.asp, line 16, column 79
WAFV_Errors = WAFV_Errors & WAValidateNM(cStr(Request.Form("qtyAvail")) & "",0,<%= Request.Form("qtyAvail")
I assume this is because I am using a form variable as the maximum number value?
How do I set the maximum number to be the hidden form element? I notice the default is set to 100, but when I insert <%= Request.Form("qtyAvail") %> it generates the syntax error.
Hope you can help with that. Thanks.
Nath.
EDIT:
I've tried changing the line of code to the following:
WAFV_Errors = WAFV_Errors & WAValidateNM(cStr(Request.Form("spCART_1_Quantity_Add")) & "",0,Request.Form("qtyAvail"),"",",.",true,1)
...but, whilst this no longer produces a syntax error, the validation doesn't work.
Here's the code for my Add to Cart button:
<form name="spCART_1_ATC_<%=rsH.Fields("heatherID").value%>" method="post" action="<%=cStr(Request.ServerVariables("SCRIPT_NAME"))%><%=WA_eCart_IIf((Request.ServerVariables("QUERY_STRING") <> ""), "?" & Request.ServerVariables("QUERY_STRING"), "")%>">
<input type="hidden" name="spCART_1_ID_Add" value="<%=rsH.Fields("heatherID").value%>" />
<p>Quantity: <br />
<input type="text" name="spCART_1_Quantity_Add" value="1" size="6" style="width: 40px;height: 20px;border: 2px solid #BACBBE;padding: 6px 0px 6px 8px;margin: 0;color: #18440D;font:14px Arial, Helvetica, sans-serif;font-weight: normal;vertical-align:middle;" />
<input type="image" src="heather-plants/btn-addtobasket.png" value="Add to Cart" name="spCART_1_ATC" alt="Add to Basket" style="vertical-align:middle;" />
<input name="qtyAvail" type="hidden" id="qtyAvail" value="<%=(rsH.Fields.Item("heatherinstock").Value)%>" />
</p>
</form>
...and here is the server validation code:
<%
if (cStr(Request.Form("spCART_1_ATC.x")) <> "") then
WAFV_Redirect = "plant-information.asp"
Session("WAVT_plantinformation_Errors") = ""
if (WAFV_Redirect = "") then
WAFV_Redirect = cStr(Request.ServerVariables("SCRIPT_NAME"))
end if
WAFV_Errors = ""
WAFV_Errors = WAFV_Errors & WAValidateNM(cStr(Request.Form("spCART_1_Quantity_Add")) & "",0,Request.Form("qtyAvail"),"",",.",true,1)
if (WAFV_Errors<> "") then
PostResult WAFV_Redirect,WAFV_Errors,"plantinformation"
end if
end if
%>