Call custom validator from control which is not the controlToValidate

685 views Asked by At

HI

i have custom validator which is to compare the value in 2 textboxes to see if 1 is greater than the other. This custom validator is applied to textbox 1. but if i change the value in textbox 2 i would like this validation to fire again so that if the user fixes the values to pass the comparrison then the validator will update. How can i do this. The custom validator is just doing client side validation.

function ValidateProbableSalesPriceAsIs(sender, args) {
    var tbxProbableSalesPriceAsIs = $("#<%= tbxProbableSalesPriceAsIs.ClientID %>").val();
    var probableSalesPriceAsIs = isNaN(parseFloat(tbxProbableSalesPriceAsIs.replace(/[,]/g, ""))) ? 0 : parseFloat(tbxProbableSalesPriceAsIs.replace(/[,]/g, ""));
    var cell = sender.ValidatorCalloutBehavior._errorMessageCell;

        var tbxProbableSalesPriceQuickSale = $("#<%= tbxProbableSalesPriceQuickSale.ClientID %>").val();
        var probableSalesPriceQuickSale = isNaN(parseFloat(tbxProbableSalesPriceQuickSale.replace(/[,]/g, ""))) ? 0 : parseFloat(tbxProbableSalesPriceQuickSale.replace(/[,]/g, ""));

        if (probableSalesPriceAsIs <= probableSalesPriceQuickSale) {
            if (cell != null) {
                cell.innerHTML = "Probable Sales Price As Is Value must be greater than Quick Sale Value";
            }
            sender.errormessage = "Probable Sales Price As Is Value must be greater than Quick Sale Value";
            args.IsValid = false;
        } 


}
1

There are 1 answers

0
Somedeveloper On BEST ANSWER

Got it myself its. tbxProbableSalesPriceQuickSale.Attributes.Add("onchange", "Page_ClientValidate('');");