3

In Struts2 jQuery plugin, we defined forms with ajax validation. But some times we want to prevent form begin validated via ajax and submitted.

I see some similar issue which changed the Struts 2 jQuery core which i prefer not to do it: struts2 jquery ajax and client side validatio not working toghether

For first try:

I add onBeforeTopics="beforeFormSubmit" and below method:

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

});

So is there any way I can prevent the form from being submitted by subscribing to onBeforeTopics?!

For second approach:

I try to prevent form submiting by:

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

But surprisingly the above will not trigger and I don't see any alert! After some tests I find the above submit event handler:

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

Can I some how do it with javascript events ?

Community
  • 1
  • 1
Alireza Fattahi
  • 42,517
  • 14
  • 123
  • 173
  • 1
    http://stackoverflow.com/a/19950126/1654265 – Andrea Ligios Feb 26 '14 at 11:05
  • @AndreaLigios: It is not working and the form is submitting! I am using struts jquery last version ( 3.7.0 ). as far as I reviewed at http://code.google.com/p/struts2-jquery/issues/detail?id=1039 this option was a suggestion and not implemented – Alireza Fattahi Feb 26 '14 at 12:33

0 Answers0