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 ?