Dear all,
i would like to contribute to this forum.
I had the necessity to execute a user function after the form validation ( really after the submit event ).
looking on the various post i've found the brillant solution of GH that was to inser a "Load Javascrip" in the on load event wuth the code reported below.
All was fine but if you want to logout from the site, joomla execute an submit and you can have or a double execution of USERFUNCTION or an validation error ( if fields are not correctly filled ).
For bypass this problem my solution is to insert the test below before the " if ( validated )" statement :
So the final code will be :
cheers.
paolo
i would like to contribute to this forum.
I had the necessity to execute a user function after the form validation ( really after the submit event ).
looking on the various post i've found the brillant solution of GH that was to inser a "Load Javascrip" in the on load event wuth the code reported below.
jQuery(document).ready(function(jQ){
var validated = false;
var form = jQ('#AuthUser_AJAX');
jQ(document).on('submit', form, function(event){
if ( validated ) {
return;
}
event.stopPropagation();
event.preventDefault();
USERFUNCTION();
form.submit();
});
});
All was fine but if you want to logout from the site, joomla execute an submit and you can have or a double execution of USERFUNCTION or an validation error ( if fields are not correctly filled ).
For bypass this problem my solution is to insert the test below before the " if ( validated )" statement :
if ( event.target[0].name == "Submit")
return;
So the final code will be :
jQuery(document).ready(function(jQ){
var validated = false;
var form = jQ('#AuthUser_AJAX');
jQ(document).on('submit', form, function(event){
if ( event.target[0].name == "Submit")
return;
if ( validated ) {
return;
}
event.stopPropagation();
event.preventDefault();
USERFUNCTION();
form.submit();
});
});
Hoping this can help someone.
cheers.
paolo