Hi indradeo,
You need to use CustomValidator ClientValidationFunction property.
Please refer below sample.
HTML
Grand Total: <asp:TextBox ID="txtGrand_Total" runat="server" /><br />
Parking Amount: <asp:TextBox ID="txtParkingAmount" runat="server" /><br />
<asp:CustomValidator runat="server" ClientValidationFunction="ValidateNumber" ForeColor="Red"
ControlToValidate="txtParkingAmount" ErrorMessage="Input Number is not valid." />
<script type="text/javascript">
function ValidateNumber(sender, args) {
var total = document.getElementById("txtGrand_Total").value;
var number = document.getElementById(sender.controltovalidate).value;
var rangeFrom = parseInt(total) - 5;
var rangeTo = parseInt(total) + 5;
if (number >= rangeFrom && number <= rangeTo) {
args.IsValid = true;
} else {
args.IsValid = false;
}
}
</script>
Screenshot