簡體   English   中英

如何創建一個調用ClientValidationFunction的函數?

[英]How to create a function that calls a ClientValidationFunction?

這有可能用Java語言做到嗎?

function MyClick(){
ValidateTime(sender, args);  // what is the right way to call it?
}

function ValidateTime(sender, args) { //sender and args;these arguments are from a validator control
}

我需要MyClick調用該ClientValidationFunction(ValidateTime)

參數會自動傳遞到ClientValidationFunction ,您只需要使用兩個參數進行定義即可:

驗證者:

<asp:CustomValidator id="CustomValidator1"
       ClientValidationFunction="ValidateTime"
       .....
       runat="server"/>

這是功能

<script language="javascript"> 
   function ValidateTime(sender, args)
   {
        if (bla...){
            arguments.IsValid = true;
        } else {
            arguments.IsValid = false;
        }
   }
</script>

如果要從其他地方使用驗證功能,我會將主要邏輯提取到一個單獨的功能中,您可以從按鈕單擊處理程序和ClientValidationFunction

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM