Pointing users to invalid elements on a form

2 views
Skip to first unread message

Allan Streib

unread,
Jun 3, 2021, 3:30:32 PMJun 3
to nitro...@googlegroups.com
This may be a basic question but I have not found out how to do what I want.

Let's say I have a form, with some elements and have wired validators to the elements.

When I submit the form, a required element is missing a value. At that point I do see the validator message below the element, but the form is long and it could be scrolled out of view.

So I want to the form scroll to the first invalid element. I'm thinking I need to use javascript to get the first element with the "LV_invalid" class, and call its scrollIntoView() method to do this. I tried adding this as a #script{} action in the element's on_invalid attribute, but it didn't seem to do anything.

Another possibly acceptable approach would be to use something like wf:flash("Please check the form for errors"), but again I'm not sure where to put this so that it runs only when there are invalid elements.

Thanks for any pointers.

Allan

Allan Streib

unread,
Jun 3, 2021, 8:06:01 PMJun 3
to nitro...@googlegroups.com
Hey, I just stumbled into the validator demos on the website, which I think will go a long way to answering ny noob questions. I'll follow up with more specific questions if I can't figure it out.

Allan
Reply all
Reply to author
Forward
0 new messages