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

  • Home
  • SEARCH
  • 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 7048107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:51:07+00:00 2026-05-28T02:51:07+00:00

I made a simple login form where a user can click on a register

  • 0

I made a simple login form where a user can click on a register button.

I loaded the register form using AJAX but it won’t keep the behaviour I scripted on the log in form even though I have used the same class names…

AJAX request:

var displayRegisterForm = function() {
    var regLink = document.getElementById("signInBoxFooter");
    regLink.addEventListener("click", function(){
        var request = new XMLHttpRequest();
        request.open("GET", "register.html");
        request.onreadystatechange = function(){
            if (request.readyState === 4 && request.status === 200){
                document.getElementById("signInBody").innerHTML = request.responseText;
            } else {
                document.getElementById("signInBody").innerHTML = "Whoops something went wrong!"
            }
        };
        request.send(null);
    },false);
}();

Form Behaviour:

var textInput2 = function(){
var inputs = document.getElementsByClassName("inputNoFocus");
for (i = 0; i < inputs.length; i++){
    var input = inputs[i];
    var busy = false;
    input.addEventListener("focus", function(e){
        var defaultValue = this.getAttribute("value");
        if(this.value === defaultValue){
            this.value = "";
            this.setAttribute("class", "inputFocus");
        }
        if(defaultValue === "Password"){
            this.setAttribute("type", "password");
            this.setAttribute("class", "inputFocus");
        }
        this.parentNode.parentNode.setAttribute("class", "divFocus");
        busy = true;
    }, false);

    input.addEventListener("blur", function(e){
        var defaultValue = this.getAttribute("value");
        if(this.value === ""){
            this.value = defaultValue;
            this.setAttribute("class", "inputNoFocus");
        }
        if(this.value === "Password"){
            this.setAttribute("type", "text");
            this.setAttribute("class", "inputNoFocus");
        }
        this.parentNode.parentNode.setAttribute("class", "divNoFocus")
        busy = true;
    },false);
}
}();

HTML (register.html)

<div class="boxBody">
    <form id="regForm">
        <div id="regTop"></div>
        <div class="divNoFocus">
            <label><input class="inputNoFocus" type="text" value="Email Address"></label>
        </div>
        <div class="divNoFocus">
            <label><input class="inputNoFocus" type="text" value="First Name"></label>
        </div>
        <div class="divNoFocus">
            <label><input class="inputNoFocus" type="text" value="Surname"></label>
        </div>
    </form>
</div>

HTML (before register.html) takes its place.

<div id="signInBody" class="boxBody">
    <form id="login">
        <div class="divNoFocus">
            <label><input class="inputNoFocus" type="text" value="Username or Email"></label>
        </div>
        <div class="divNoFocus">
            <label><input class="inputNoFocus" type="text" value="Password"></label>
        </div>
    </form>
</div>
  • 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-05-28T02:51:07+00:00Added an answer on May 28, 2026 at 2:51 am

    I think you need to re-bind the form behaviour to the newly loaded content. So,

    if (request.readyState === 4 && request.status === 200){
    document.getElementById("signInBody").innerHTML = request.responseText;
    // Wrap your form behaviour in a function that you can call here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On Windows, testing different OSes is made simple using VMs. Is there a simple
We made a simple application and using GoogleAppEngineLauncher (GAEL) ran that locally. Then we
I made a simple counter, but it increments by 2 instead of 1. $handle
I've made a simple http server using Twisted, which sends the Content-Type: multipart/x-mixed-replace header.
Possible Duplicate: How does StackOverflow generate its SEO-friendly URLs? I made a simple form
I'm starting a simple web application, using ASP.Net MVC 3. I made a few
I made the simple j2me login application, code is below. It's working perfectly on
I have a form where an user can post a global notice into the
I have a simple Login page made with JSF 2.0. Usually in every login
last year I made really simple blog system. it allows user to authorize, posting,

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.