Sitekit Forums
Developer Discussion - Positioning of form validation message
James Bentley
Posted on 14 August 2014
James Delaney
AdminPosted on 20 August 2014
You could use script to scroll to an error messages? JQuery could do it with something along the lines of within a document.ready function:
$('body').scrollTo('.formValidationError');
the formValidationError span tag does not exist unless an error has been identified so most of the time the trigger will not fire but it's there in the event it is needed.
James Bentley
Posted on 21 August 2014
Good thinking - I hadn't tried that. I'll give it a whirl.
James Bentley
Posted on 24 November 2014
Finally got round to trying this and for some reason it's not working.
The following is good though, for scrolling straight to either the validation message, or "thank you" message if you're using one.
$('html, body').animate({
scrollTop: $(".formValidationError, .formSubmissionMessage").offset().top
}, 500);
I've set this to half a second (500 milliseconds) for the animation. Change the number to change the speed. Hopefully others might find this useful.
James Bentley
Posted on 24 November 2014
Sorry - annoyed myself with the inconsistent use of single/double quotes there.
$('html, body').animate({
scrollTop: $('.formValidationError, .formSubmissionMessage').offset().top
}, 500);
That's better.