简体   繁体   中英

Call custom validator from control which is not the controlToValidate

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;
        } 


}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM