TestSubject09
TestSubject09

Reputation: 411

call javascript from control with ValidationGroup

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>

Upvotes: 0

Views: 1453

Answers (1)

cptScarlet
cptScarlet

Reputation: 6136

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?

Upvotes: 1

Related Questions