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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:35:15+00:00 2026-06-02T21:35:15+00:00

Hi read the changes recommended to make from previous post yet i cant see

  • 0

Hi read the changes recommended to make from previous post yet i cant see the JS working and i have no errors could somebody please tell me where im going wrong ? thanks
This example scenario changes the color of the text when the user has not inputted enough characters or too many characters i was also wondering if it would be possible to change the color of the text box to red also.

<script type="text/javascript">
                function checkForm()
                {
                    var username = document.getElementsById('username').value;
                    if(username.length<5)
                    {
                        alert("Username is to short");
                        return false;
                    }
                    else if (username.lenght<16)
                    {
                        alert("Username is to long");
                        return false;
                    }
                    else
                    {
                    return true;    
                    }

                }

                function checkUsername()
                {
                    var username = document.getElementsById('username').value;
                    var element = document.getElementsById('username1');
                    if(username.lenght<5)
                    {
                        element.innerHTML = "Username is to short";
                        element.style.color = "red";
                    }
                    else if (username.lenght>16)
                    {
                        element.innerHTML = "Username is to long";
                        element.style.color = "red";
                    }
                    else
                    {
                        element.innerHTML = "Valid Username";
                        element.style.color = "green";
                    }
                }

    </script>
        <p><b><h3>Welcome User Please Register</h3></b></p>
        <form action="registerUserProcess.php" id="registerUserForm" method="post" name="registerUserForm" onSubmit='return checkForm();'>

    <table> 
    <tr><td><label id="username1">Username</label></td><td><input id="username" type="text" size="16" onBlur='checkUsername();'/></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-02T21:35:17+00:00Added an answer on June 2, 2026 at 9:35 pm

    Problem is with your labels. When you call document.getElementById('username'), js searches the document for id == username and it finds a label, not a textfield. Switch your label id to sth like label_username and add id='username' to you input definition.

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

Sidebar

Related Questions

Problem: We have to read from a proprietary binary file at work. It changes
I'm currently trying to read in an XML file, make some minor changes (alter
I read this post but I can't get it working: Change Background Color... I
I have to create an app that will read in some info from a
i was only able to read up that ASP.NET detects changes to specific files
I'd read that when renaming files in Git , you should commit any changes,
How to upgrade read only sqlite database I have tried to change to SQLiteDatabase.OPEN_READWRITE);
I have just read a question regarding initializing multidimensional vectors ( question ) and
I have an app in which the app flow is different from Android standard:
I have read this excellent blog entry on the woes of strong naming and

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.