Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2003
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Triggering a link from a function and form validation

    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.

  • #2
    New Coder
    Join Date
    Dec 2003
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's one solution that almost fits the bill.

    form.element.focus()

    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.

    Thanks

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Then use an anchor an give that focus

  • #4
    New Coder
    Join Date
    Dec 2003
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    good idea. i'll try it. thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •