View Full Version : Triggering a link from a function and form validation

05-09-2004, 10:06 PM
I am hoping someone can assist me with a part of the form validation I am working on. Here's an overview.

The user fills out a form.
The user clicks the submit button.
The form's onsubmit handler calls a function to validate the form.
If there are fields missing values, the function alerts the user with a message.
The user clicks 'OK' in the alert box.
The function returns false.
The form is not submitted.

Then I would like the page to jump to an anchor located at the top of the form.

How do I make the page move to the anchor from within the function that was called?

Thanks for the assistance.

05-09-2004, 11:42 PM
Here's one solution that almost fits the bill.


Gives the missing form element focus and (in some browsers) moves the page to that element.

I would still prefer to be returned to the top of the form. If anyone has an idea I would appreciate the help.


Willy Duitt
05-10-2004, 01:17 AM
Then use an anchor an give that focus

05-10-2004, 02:15 AM
good idea. i'll try it. thanks!