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 9215037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:06:41+00:00 2026-06-18T02:06:41+00:00

So my code basically is to tell users what’s wrong in their registration, everything

  • 0

So my code basically is to tell users what’s wrong in their registration, everything works but one thing. The Div should update the text field to say what’s wrong with their registration, but it is not, here is my JavaScript

window.onload = initPage;
submitBtn = document.getElementById("submit");
errorText = document.getElementById("errortext");


function initPage() {
    document.getElementById("password2").onkeyup = checkPassword;
    document.getElementById("password2").onblur = checkPassword;
    document.getElementById("email2").onkeyup = checkEmail;
    document.getElementById("email2").onblur = checkEmail;
    submitBtn.disabled = false;
}

function checkPassword() {
    var password1 = document.getElementById("password1").value;
    var password2 = document.getElementById("password2").value;
    if (password1 != password2) {
        document.getElementById("password1").className = "denied";
        document.getElementById("password2").className = "denied";
        submitBtn.disabled = true;
        document.getElementById("submit").className = "denied";
        errorText.innerHTML = "Passwords do not match.";
    } else {
        document.getElementById("password1").className = "password2";
        document.getElementById("password2").className = "password2";
        document.getElementById("submit").className = "button1";
        submitBtn.disabled = false;
        errorText.innerHTML = "";
    }
}

function checkEmail() {
    var email1 = document.getElementById("email1").value;
    var email2 = document.getElementById("email2").value;
    if (email1 != email2) {
        document.getElementById("email1").className = "denied";
        document.getElementById("email2").className = "denied";
        submitBtn.disabled = true;
        document.getElementById("submit").className = "denied";
        errorText.innerHTML = "Emails Do Not Match.";

    } else {
        document.getElementById("email1").className = "regtext";
        document.getElementById("email2").className =  "regtext";
        submitBtn.getElementById("submit").disabled = true;
        document.getElementById("submit").className = "button1";
        errorText.innerHTML = "";
    }
}

here is my div

<tr><td colspan="2"><div id="errortext"></div></td></tr>
  • 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-18T02:06:42+00:00Added an answer on June 18, 2026 at 2:06 am

    You’re probably trying to access that div before the DOM is fully constructed. Put that code in with the initPage function. You’ll need a variable outside of the scope of that function so your other functions can access them. You should put all of this in a closure to avoid creating global variables.

    Ex:

    (function(){    
        var submitBtn;
        var errorText;
    
        function initPage() {
            submitBtn = document.getElementById("submit");
            errorText = document.getElementById("errortext");
            document.getElementById("password2").onkeyup = checkPassword;
            document.getElementById("password2").onblur = checkPassword;
            document.getElementById("email2").onkeyup = checkEmail;
            document.getElementById("email2").onblur = checkEmail;
            submitBtn.disabled = false;
        }
    
        // This next line should be under the declaration above
        window.onload = initPage;
    
        // ...
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I would like to tell MSTest to execute a bit of code before
This code basically translates characters based on position in one string to the character
The following code basically works as expected. However, to be paranoid, I was wondering,
Basically the code inside the displayCharityList () works. I decided to put that code
Can someone please tell me where I'm going wrong with this piece of code?
Can anyone tell me where I am wrong? I can't figure it out.... Basically
I can't tell what's wrong with my code: #include <iostream> #include <string> using namespace
I am basically using the same code that works in another scrip into this
Can anyone tell me why this code generates queue after starting the threads? Basically,
My code basically needs to start up a simple chat server with a client.

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.