Placement of Success Message

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #10036060
    MoiraAllen
    Participant

    Hi – I am wondering if it is possible to change the placement of the Success Message. Once my form is completed and submitted the Success Message is at the top and hidden by my sticky menu. Is it possible to have the message appear at the bottom go the page?


    #10036069
    Support
    Keymaster

    Hello Moira,

    You can change the HTML position of success/error message like the image below:

    Move the HTML to after the last form-row.

    Another good way is scroll to message div when send the form. For it change this part of code at “js/views/view.contact.js”:

    ...
    ....
    ......
    }).always(function(data, textStatus, jqXHR) {
    
    	$errorMessage.empty().hide();
    
    	if (data.response == 'success') {
    
    		// Uncomment the code below to redirect for a thank you page
    		// self.location = 'thank-you.html';
    
    		$messageSuccess.removeClass('d-none');
    		$messageError.addClass('d-none');
    
    		// Reset Form
    		$form.find('.form-control')
    			.val('')
    			.blur()
    			.parent()
    			.removeClass('has-success')
    			.removeClass('has-danger')
    			.find('label.error')
    			.remove();
    
    		if (($messageSuccess.offset().top - 80) < $(window).scrollTop()) {
    			$('html, body').animate({
    				scrollTop: $messageSuccess.offset().top - 80
    			}, 300);
    		}
    
    		$form.find('.form-control').removeClass('error');
    
    		$submitButton.val( submitButtonText ).attr('disabled', false);
    
    		// CODE FOR SCROLL TO SUCCESS DIV WHEN FORM IS SENT
    		$('html, body').animate({
    			scrollTop: $messageSuccess.offset().top - 80
    		}, 300);
    		
    		return;
    
    	} else if (data.response == 'error' && typeof data.errorMessage !== 'undefined') {
    		$errorMessage.html(data.errorMessage).show();
    	} else {
    		$errorMessage.html(data.responseText).show();
    	}
    
    	$messageError.removeClass('d-none');
    	$messageSuccess.addClass('d-none');
    
    	if (($messageError.offset().top - 80) < $(window).scrollTop()) {
    		$('html, body').animate({
    			scrollTop: $messageError.offset().top - 80
    		}, 300);
    	}
    
    	$form.find('.has-success')
    		.removeClass('has-success');
    		
    	$submitButton.val( submitButtonText ).attr('disabled', false);
    
    });
    ...
    ....
    ....

    We hope this helps!

    Please try that and let us know if you need further assistance.

    Kind Regards,

    Rodrigo.


    If you are satisfied with EZY HTML and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads


    #10036072
    MoiraAllen
    Participant

    Thanks, Rodrigo. I moved the HTML position of success/error message to after the </form> tag.

    I opened the js/views/view.contact.js page and added the code you sent. But…the form does send but the “submit” button says “loading” and doesn’t change.

    Thanks for your continued help.


    #10036073
    Support
    Keymaster

    Hello Moira,

    Normally this infinite loading occurs when has some javascript error. But I did a test in your website now and couldn’t reproduce the issue with infinite “loading” button. The form is sending normally.

    Please try to clear your browser cache.

    Also please change the JS code to this new:

    ...
    ....
    ......
    }).always(function(data, textStatus, jqXHR) {
    
    	$errorMessage.empty().hide();
    
    	if (data.response == 'success') {
    
    		// Uncomment the code below to redirect for a thank you page
    		// self.location = 'thank-you.html';
    
    		$messageSuccess.removeClass('d-none');
    		$messageError.addClass('d-none');
    
    		// Reset Form
    		$form.find('.form-control')
    			.val('')
    			.blur()
    			.parent()
    			.removeClass('has-success')
    			.removeClass('has-danger')
    			.find('label.error')
    			.remove();
    
    		// CODE FOR SCROLL TO SUCCESS DIV WHEN FORM IS SENT
                    if (($messageSuccess.offset().top - 80) < $(window).scrollTop()) {
    			$('html, body').animate({
    				scrollTop: $messageSuccess.offset().top - 120
    			}, 300);
    		}
    
    		$form.find('.form-control').removeClass('error');
    
    		$submitButton.val( submitButtonText ).attr('disabled', false);
    		
    		return;
    
    	} else if (data.response == 'error' && typeof data.errorMessage !== 'undefined') {
    		$errorMessage.html(data.errorMessage).show();
    	} else {
    		$errorMessage.html(data.responseText).show();
    	}
    
    	$messageError.removeClass('d-none');
    	$messageSuccess.addClass('d-none');
    
    	if (($messageError.offset().top - 80) < $(window).scrollTop()) {
    		$('html, body').animate({
    			scrollTop: $messageError.offset().top - 80
    		}, 300);
    	}
    
    	$form.find('.has-success')
    		.removeClass('has-success');
    		
    	$submitButton.val( submitButtonText ).attr('disabled', false);
    
    });
    ...
    ....
    ....

    * Note I changed the offset value from 80 to 120:

    scrollTop: $messageSuccess.offset().top - 120

    This will position better the final scroll position when the form is sent (without stay behind the sticky menu).

    Regarding change the position of HTML success/error messages, this is not needed if you are using the JS solution. But inspecting your code we can still see the HTML at very top of the form:

    We hope this helps!

    Kind Regards,

    Rodrigo.


    If you are satisfied with EZY HTML and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads


    #10036103
    MoiraAllen
    Participant

    Hi Rodrigo – still having issues with the submit. I have 4 forms and have moved the “success/error” code to the bottom as well as changing the code in the view-contact.js page with the new one you sent. BUT still having the same issue. It just says “loading”. I tried this on another computer and had the same result.
    One thing I notice is that in Dreamweaver it is saying there is an error in the js: ERROR:”jqXHR is defined but never used [n0-unused-vars]
    I don’t know if this is important.

    Thanks for your help, Moira


    #10036104
    Support
    Keymaster

    Hello,

    Inspecting your code I saw you put the success and error messages outside the <form>...</form>. You need maintain inside the form:

    Change to the position marked with green line in the above image.

    Please try that and let us know if you need further assistance.

    Kind Regards,

    Rodrigo.


    If you are satisfied with EZY HTML and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads


    #10036106
    MoiraAllen
    Participant

    Of course! That makes sense.

    I did that and now I getting this message: Error! There was an error sending your message.
    {“code”:”MethodNotAllowedError”,”message”:”POST is not allowed”}

    So what else do I need to fix 🙂


    #10036110
    Support
    Keymaster

    Hello Moira,

    I did a test now and seems to be working normally:

    Maybe you already resolved the issue ?

    If you need further assistance feel free to contact us.

    Kind Regards,

    Rodrigo.


    If you are satisfied with EZY HTML and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads


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

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