Hi guys I would like to scroll to the first erroneous input on the product page. Currently it doesn't and stays at the bottom.
You then have to manually scroll up till you see the swatch option group that is not selected. So, no visual cue to show at bottom.
I tried to run a on DOMNodeInserted function to see if it has class validation-advice. And if so run the scroll to element.
Didn't works as expected.
So would anyone how know to edit the validation script bottom of product view page in rwd theme or validation.js in magento-root/js/varien/prototype to scroll to the first input/ swatch where this is required is shown.
Using the answer below I attempted to scroll to the first error (First element element without swatch select).
But, it doesn't work, as previous validation is still being used thus add to cart has to be pressed twice, logically working one step back.
Using this line I logged the following:
Showing that first submit returns no element, even though on purpose iv'e selected no swatches, so every option has error. Second submit picks up the error elements. Then I have chosen a swatch for the first option and pressed add to cart again, still it hasn't picked up that the first element no longer has error, the second submit picks it up. This trend continues throughout.
Is the else in the wrong place ?