2011-02-08 50 views
0

HI呼叫從控制自定義驗證其不是的ControlToValidate

我有自定義驗證這對值在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; 
     } 


} 

回答

0

明白了吧。 tbxProbableSalesPriceQuickSale.Attributes.Add(「onchange」,「Page_ClientValidate('');」);