Jeff,
Please find an example below. Please also note it's easy to prepare a page
that skips your client validation therefore server validation should be
always present regardless of the client scripts:
<div>
<asp:TextBox runat="server" ID="quantityOrdered" Text="0" />
<asp:RequiredFieldValidator runat="server" ID="rfv1"
ErrorMessage="Please enter order quantity"
ControlToValidate="quantityOrdered" Display="Dynamic" />
<asp:RangeValidator runat="server" ID="rv1"
ErrorMessage="A valid number 0 ... 2000000"
ControlToValidate="quantityOrdered" Display="Dynamic"
MinimumValue="0" MaximumValue="2000000"
Type="Integer" />
</div>
<div>
<asp:TextBox runat="server" ID="laminatedCount" Text="0" />
<asp:RequiredFieldValidator runat="server" ID="rfv2"
ErrorMessage="Please enter number of items for lamination"
ControlToValidate="quantityOrdered" Display="Dynamic" />
<asp:RangeValidator runat="server" ID="rv2"
ErrorMessage="A valid number 0 ... 2000000"
ControlToValidate="laminatedCount" Display="Dynamic"
MinimumValue="0" MaximumValue="2000000"
Type="Integer" />
</div>
<div>
<asp:CustomValidator runat="server" ID="cv"
ControlToValidate="laminatedCount" Display="Dynamic"
ClientValidationFunction="ValidateQuantity"
OnServerValidate="cv_ServerValidate"
ErrorMessage="Number of laminated items must be less or equal items
ordered" />
</div>
<script type="text/javascript">
function ValidateQuantity(sender, e)
{
// ensure all the validators tested until now are valid
if (Page_IsValid)
{
var ordered =
parseInt(document.getElementById('<%=quantityOrdered.ClientID %>').value);
var laminated =
parseInt(document.getElementById('<%=laminatedCount.ClientID %>').value);
e.IsValid = laminated <= ordered;
}
}
</script>
<asp:Button runat="server" ID="submit" Text="Submit" />
HTH