- This topic has 8 replies, 2 voices, and was last updated 5 years, 4 months ago by
Support. This post has been viewed 1294 times
-
AuthorPosts
-
February 26, 2021 at 9:23 pm #10036472
frankict
ParticipantHello,
sorry to bother you again but I got a problem using validator and everything that could prevent multiple form submission.I’ll ad here (private post) user access to check this but, to explain the problem, I need to use validator and disable the submit button after the click.
On that page if you fastly click “invia” the form will submit a lot of request.
I can achieve to “hide” button on submit but I cannot achieve this while using validator since, once clicked with validator, the submit will be not clickable anymore.I think I need your help,
February 26, 2021 at 9:24 pm #10036473frankict
ParticipantThis reply has been marked as private.February 27, 2021 at 12:39 am #10036483Support
KeymasterHello,
Do not worry with questions, we are here to help 🙂
The
submitHandlermethod of validation plugin is what you are looking for. Please change the “basic” code at “js/examples/examples.validation.js” to:// basic $("#form").validate({ highlight: function( label ) { $(label).closest('.form-group').removeClass('has-success').addClass('has-error'); }, success: function( label ) { $(label).closest('.form-group').removeClass('has-error'); label.remove(); }, errorPlacement: function( error, element ) { var placement = element.closest('.input-group'); if (!placement.get(0)) { placement = element; } if (error.text() !== '') { placement.after(error); } }, submitHandler: function(form) { var $form = $(form), $submitButton = $(this.submitButton); // Disable the button and prevent multiple clicks $submitButton.val( 'Sending...' ).attr('disabled', true); } });Please try that and let us know if you need further assistance.
Kind Regards,
Rodrigo.
If you are satisfied with Porto Admin and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads
February 27, 2021 at 1:38 am #10036488frankict
ParticipantHi Rodriguo,
I’ve replaced the file but now the button is disabled and the form is not submitted at all.
You can check that at the same link.Could you give a look at that?
p.s.
If I try just to add the “different code” here :, submitHandler: function(form) { var $form = $(form), $submitButton = $(this.submitButton); // Disable the button and prevent multiple clicks $submitButton.val( 'Sending...' ).attr('disabled', true); }everything will not work as before.
February 27, 2021 at 6:42 am #10036493Support
KeymasterHello,
Oh sorry. I forgot to include the code that submit the form. Please try with:
submitHandler: function(form) { var $form = $(form), $submitButton = $(this.submitButton); // Disable the button and prevent multiple clicks $submitButton.val( 'Sending...' ).attr('disabled', true); // Submit $form.submit(); }Please try that and let us know if you need further assistance.
Kind Regards,
Rodrigo.
If you are satisfied with Porto Admin and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads
February 27, 2021 at 6:46 pm #10036499frankict
ParticipantHello Rodriguo,
first of all I’m really sorry for bothering you so much.
I’m trying by myself reading some docs/stackoverflow but I’m unable to do this as intended.The code with “submit” is working but this seems to cause another strange error.
After the submit everything will freeze for about 3 seconds ….. the button will not change it value and the submit will start.It seems to be a “freeze” …. something like a sleep() command.
Could you give a check on this?
p.s.
– same link
– new edited code is http://mybsrl.com/myb/js/examples/examples.validation.js
March 1, 2021 at 11:30 pm #10036516Support
KeymasterHello,
Oh sorry! The reason of the issue is the submit code I sent for you. Please try changing to:
// Submit $form[0].submit();
Please try that and let us know if you need further assistance.
Kind Regards,
Rodrigo.
If you are satisfied with Porto Admin and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads
March 2, 2021 at 12:54 am #10036529frankict
ParticipantGreat one!
It seems to work!!!!Thanks a lot Rodriguo!
March 2, 2021 at 3:49 am #10036546Support
KeymasterHello,
Great the issue is now resolved!
If you need further assistance feel free to contact us.
Kind Regards,
Rodrigo.
-
AuthorPosts
This topic is marked as "RESOLVED" and can not rceive new replies.