从控件调用自定义验证器,而不是controlToValidate

时间:2011-02-08 15:06:19

标签: javascript customvalidator

HI

我有自定义验证器,用于比较2个文本框中的值,以查看1是否大于另一个。此自定义验证器应用于文本框1.但如果我更改文本框2中的值,我希望再次触发此验证,以便如果用户修复值以通过比较,则验证程序将更新。我怎样才能做到这一点。自定义验证器正在进行客户端验证。

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 个答案:

答案 0 :(得分:0)

得到它自己。 tbxProbableSalesPriceQuickSale.Attributes.Add(“onchange”,“Page_ClientValidate('');”);