• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Smooth scroll to top of the form after AJAX valida

Smooth scroll to top of the form after AJAX valida 11 years 11 months ago #23113

  • drazmyslovich
  • drazmyslovich's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 1
Hi, all,

I recently worked with a quite long form and it became nice to have an autoscroll to the top of the form after failed ajax validation. Otherwise the user wouldn't understand the problem if the last fields filled correctly, because the error message in on the top.
So, if somebody needs also to have a smooth scrolling here is the way to do it. In the script /components/com_rsform/assets/js/script.js add function:
function rsfp_scrollTop(element, to)
{
	var animateScroll = function(){
		if (element.scrollTop == to) 
			return;
		perTick = Math.min(element.scrollTop - to, 40);
		element.scrollTop -= perTick;
		setTimeout(animateScroll, 10);
	};
	animateScroll();
}
Then in the end of function ajaxValidation find the block and add 1 line
if (success == false && document.getElementById('rsform_error_' + formId))
{
	try {
		document.getElementById('rsform_error_' + formId).style.display = '';
		rsfp_scrollTop(document.body, form.offsetTop); // <--- This will do the job
	}
	catch (err) { }
}

Hope this will help somebody.
The administrator has disabled public write access.
The following user(s) said Thank You: sean.gruenboeck

Smooth scroll to top of the form after AJAX valida 11 years 9 months ago #24319

  • micah4
  • micah4's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
Thank you! I found this post last night and just gave it a shot. Took me about 10 minutes and it works great!

Micah
The administrator has disabled public write access.

Smooth scroll to top of the form after AJAX valida 11 years 9 months ago #24442

Thanks for that nice idea, but unfortunately, not working for me.

I followed the instructions, maybe I miss a tag or placeholder in my customuzed form.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!