Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scroll on submittal fail #14

Open
harboradmin opened this issue Feb 14, 2013 · 2 comments
Open

scroll on submittal fail #14

harboradmin opened this issue Feb 14, 2013 · 2 comments

Comments

@harboradmin
Copy link

Is there a way to amend the submit function so that if the validation fails, the window scrolls up to the first error?

Example:
http://beta.harborcompliance.com/registration-order-page1.php

What's happening is that a user may, in haste, scroll down and put in their contact information and fail to select the two drop-downs closer to the top of the page. They repeatedly click Submit, unaware that there is an error message closer to the top of the page. The drop-down error message is set to show onBlur.

Any help would be appreciated. I love this tool!

Thanks,
Megan

@adityamenon
Copy link

I tried inspecting the sayHello (LiveValidation) object on the home page for this project, but couldn't find any property that shows all the invalid fields in an array or something like that. There's just sayHello.validations that gives a list of validation rules applied to the fields in the form. If it were an array of invalidated fields, I suppose the matter would have been simpler.

@cortopy
Copy link

cortopy commented Mar 4, 2015

@harboradmin could this work for you?

If you're also using jQuery, it's possible to scroll screen to the first input with error class using this function.

I've also added an animation to make things smoother and the window will have a margin on top of 100 (just personal preference)

$( '#yourFormSubmitButton' ).click( function() {
    var areAllValid = LiveValidation.massValidate( [ input1, input2 ] );
    $j('html, body').animate({
            scrollTop: $j ( '.LV_invalid_field').first().offset().top - 100
        }, 1000);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants