Struts 2 jquery plugin prevent form submit

In the Struts2 jQuery plugin, we defined forms with ajax validation. But several times, we want the form to be checked using ajax and submitted.

I see some similar problem that changed the core of the JQuery Struts 2 kernel, which I prefer not to do: struts2 jquery ajax and client side validatio do not work toghether

For the first attempt:

I add onBeforeTopics = "beforeFormSubmit" and below method:

$.subscribe("beforeFormSubmit", function(event, data) {
// Here nothing can stop event!!

});

So that I can prevent form submission by subscribing to onBeforeTopics ?!

For the second approach:

I am trying to prevent form submission:

$( "#loginForm" ).submit(function( event ) {
    alert('Before submit');
    event.preventDefault();
});

, ! :

<s:submit/> //This will trigger the submit event
<sj:submit/> //This will NOT trigger the submit event

javascript-?

+3

All Articles