0

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

<asp: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>

1 Answer 1

1

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.