开发者

call javascript from control with ValidationGroup

开发者 https://www.devze.com 2022-12-08 12:30 出处:网络
How can I call a js function from the \"onclientclick event\" of a button if this button has a ValidationGroup set ??

How can I call a js function from the "onclientclick event" of a button if this button has a ValidationGroup set ??

<asp:开发者_JAVA技巧Button ID="btnTest" runat="server" Text="Test" OnClick="btnTest_Click"
                        ValidationGroup="ValidateMail" OnClientClick="javascript:return checkTest()" />

    <script>
    checkTest()
    {
      if(val)
       return true
     else return false
    }
    </script>


It looks like you are trying to validate something on your button click.

If you are, instead of doing the validation on the button click handler, I would add a validator and have it call your checkTest() function. Don't forget to add the validator to the "ValidateMail" validation group and set CausesValidation="true" on the button.

This will cause all of the validators in the ValidateMail validation group to fire.

Is this what you were after or did I miss the point of your question?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号