Reputation: 2209
I have simple JSF form and onclick event inside submit button (google analytics event tracking). Is it posible to somehow disable onclick event when jsf validation fails?
Upvotes: 0
Views: 679
Reputation: 1108632
That's not possible. The onclick is fired before the request is sent to server. You basically want to fire it after the response has returned with a successful outcome.
There are several ways to achieve this:
Perform validation in JavaScript instead (not recommended).
Send tracking request from inside JSF bean's action method instead.
Send tracking request inside a (conditionally rendered) <script>
element on result page instead.
Upvotes: 1