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
Hi Paolo,
Thank you!🙂
Please also check a brief way to do this here, which has been implemented recently:
http://www.chronoengine.com/faqs/70-cfv5/5230-validation-customization-in-cfv5.html
Regards,
Max
Thank you!🙂
Please also check a brief way to do this here, which has been implemented recently:
http://www.chronoengine.com/faqs/70-cfv5/5230-validation-customization-in-cfv5.html
Regards,
Max
Hi Max,
is a pleasure to contribute to this great product.
My post is only for addressing a problem i had recently ( not with CF ).
Joomla, when you press the exit button, submit the form. If you have the empty form, all works correctly, if vice versa you have an invalid value in one field required you can't exit until you don't fill the input with a correct value.
this imply that you can have a double insert or double event ( unwanted ) .
:-)
your suggestion is great and usefull, but i don't thing solve my issue ... :-)
thanks again for the opportunity to contribute.
Paolo
is a pleasure to contribute to this great product.
My post is only for addressing a problem i had recently ( not with CF ).
Joomla, when you press the exit button, submit the form. If you have the empty form, all works correctly, if vice versa you have an invalid value in one field required you can't exit until you don't fill the input with a correct value.
this imply that you can have a double insert or double event ( unwanted ) .
:-)
your suggestion is great and usefull, but i don't thing solve my issue ... :-)
thanks again for the opportunity to contribute.
Paolo
Hi Paolo,
I'm not sure what 'Exit' button you are pressing here? Is this the Joomla! LogOut button or something else?
Bob
I'm not sure what 'Exit' button you are pressing here? Is this the Joomla! LogOut button or something else?
Bob
Hi Bob, is the LogOut Button on the Login module.
:-)
:-)
The button on another form (login) should not submit the form, but it actually reloads the page, and if you are on the submit url then the submit routine is re-executed, however, none of the js submit event functions will rerun.
You can solve this by adding some security to the form, to prevent direct submit url access!
Regards,
Max
You can solve this by adding some security to the form, to prevent direct submit url access!
Regards,
Max
Dear Max, i'm absolutely a nerd and this is my first site developed in php.
Furthermore my knowledge in html is not as good as i want.
Following your suggestion i've investigated more on the specified form and i've seen this piece of code :
" <form action="/index.php/it/" method="post" id="login-form" class="form-vertical">
<div class="logout-button">
<input type="submit" name="Submit" class="btn btn-primary" value="Esci" />
<input type="hidden" name="option" value="com_users" />
<input type="hidden" name="task" value="user.logout" />
<input type="hidden" name="return" value="aW5kZXgucGhwP0l0ZW1pZD0xMDE=" />
<input type="hidden" name="2c64a3f0aaa7901ddfb5b80cfd74c7d4" value="1" /> </div>
</form>
"
Is correct to assume that the click on button execute a submit ?
thanks for your response
Paolo
Furthermore my knowledge in html is not as good as i want.
Following your suggestion i've investigated more on the specified form and i've seen this piece of code :
" <form action="/index.php/it/" method="post" id="login-form" class="form-vertical">
<div class="logout-button">
<input type="submit" name="Submit" class="btn btn-primary" value="Esci" />
<input type="hidden" name="option" value="com_users" />
<input type="hidden" name="task" value="user.logout" />
<input type="hidden" name="return" value="aW5kZXgucGhwP0l0ZW1pZD0xMDE=" />
<input type="hidden" name="2c64a3f0aaa7901ddfb5b80cfd74c7d4" value="1" /> </div>
</form>
"
Is correct to assume that the click on button execute a submit ?
thanks for your response
Paolo
Hi Paolo,
What's the url in the browser's address bar before you click the logout button ?
regards,
Max
What's the url in the browser's address bar before you click the logout button ?
regards,
Max
Hi Max,
sorry for the late response .... 😟
the url in the address bar is "http://www.e-fotoservice.com/index.php/it/adesione-evento-3"
🙂
sorry for the late response .... 😟
the url in the address bar is "http://www.e-fotoservice.com/index.php/it/adesione-evento-3"
🙂
Do you have the form inside a module or a plugin ?
anyway, please check my answer here:
http://www.chronoengine.com/forums/posts/t97427/p335905/execute-function-after-summit.html#p335905
Regards,
Max
anyway, please check my answer here:
http://www.chronoengine.com/forums/posts/t97427/p335905/execute-function-after-summit.html#p335905
Regards,
Max
Thanks Max for your suggestion.
Nice night.
Paolo
Nice night.
Paolo
This topic is locked and no more replies can be posted.