Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8783785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:54:58+00:00 2026-06-13T20:54:58+00:00

I am writing a validation script for an HTML form. The script makes a

  • 0

I am writing a validation script for an HTML form. The script makes a list of errors appear at the top of the document, so that the user can see (and correct) them all at once. I’d like the focus to move to that error list when the document reloads after the validation script runs, but this isn’t working, and heaven help me I can’t see why. Any tips would be very much appreciated. Thank you!

Here is the JS

function validate(survey) {
    var error=document.createElement("text");
    error.innerHTML=" ";

    var x=document.survey.member_email.value;
    if (x==null || x=="")  {
        error.innerHTML+="<li>Please enter an email address</li>" 
        var vp=document.getElementById("validate_place");
        vp.appendChild(error);
        vp.focus( );      //  Here is the focus command   -->//
        return false;
        } 
    return true;
}

And here are the validation lines in HTML:

<form action="survey_processing.php" method="post"  onsubmit="return validate(this);"  name="survey" id="survey" >

<div id="validate_place" > </div>  <!--- empty div to insert validation correction info if needed -->
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:54:59+00:00Added an answer on June 13, 2026 at 8:54 pm

    By setting the tabindex attribute of the div to -1 you enable the ability to pass focus to it programatically. (scroll down to tabindex at the MDN article for more details)

    <div id="validate_place" tabindex="-1"> </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a PropertiesMustMatch validation attribute that can take a string property name as
I am writing a basic jQuery form validation script and I have something like
I'm writing a form validation script for a form with multiple ratings, and I'd
I'm writing a form validation script and would like to validate a given field
I'm writing a user control that uses jquery.validate instead of the validation controls to
I have a strange problem with the validation I am writing on a form.
Writing htaccess that allows me to remove index.php from the URL can confuse search
Writing documentation in html requires some code examples. What to do with characters that
Currently I'm writing a unit test for a component that does datetime specific validation.
I was writing a simple login form, everything works fine (validation etc.) but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.