SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2006
    0 Post(s)
    0 Thread(s)

    Apply CSS or Formatting To Focus

    Hello, I'm a php guy and I'm pretty much terrible with javascript. I've setup a form validation script and it's working well.

    When a form field doesn't meet my criteria, the given field takes the focus. This is the good part.

    The bad part is the form field with focus is at the very very top of the browser page (both IE and Firefox). The error message (a div that is triggered when the validation detects an error) is not visible. I have to scroll up to see the text.

    This is VERY unintuitive and it really needs to be fixed for the validation to be user friendly.

    My site is in the final stages of development. I've got a feeling that I've got a margin set in my CSS that is making the focus go all the way to the top of the page. I could be wrong.

    How do I format the focus so that it displays towards the center of the page exposing my error message?

    Home Recording Forum -
    Make 60% Commission Pushing my new mega system
    Killer Home Recording

  2. #2
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Bath, UK
    0 Post(s)
    0 Thread(s)
    You could try setting scrollTop, but a better solution would be to display the error messages beside the offending inputs.
    Hello World


Posting Permissions

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