post multiple submit + validator

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #10036472
    frankict
    Participant

    Hello,
    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,


    #10036473
    frankict
    Participant
    This reply has been marked as private.
    #10036483
    Support
    Keymaster

    Hello,

    Do not worry with questions, we are here to help 🙂

    The submitHandler method 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


    #10036488
    frankict
    Participant

    Hi 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.


    #10036493
    Support
    Keymaster

    Hello,

    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


    #10036499
    frankict
    Participant

    Hello 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


    #10036516
    Support
    Keymaster

    Hello,

    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


    #10036529
    frankict
    Participant

    Great one!
    It seems to work!!!!

    Thanks a lot Rodriguo!


    #10036546
    Support
    Keymaster

    Hello,

    Great the issue is now resolved!

    If you need further assistance feel free to contact us.

    Kind Regards,

    Rodrigo.


Viewing 9 posts - 1 through 9 (of 9 total)

This topic is marked as "RESOLVED" and can not rceive new replies.