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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:47:16+00:00 2026-06-03T06:47:16+00:00

Hi, I have this code and I can’t get it to work. I’m new

  • 0

Hi, I have this code and I can’t get it to work. I’m new with Ajax jQuery and JavaScript so please be nice 🙂 and thank you for the help 🙂
This code should be a simple form validation but when I tab in to the next input box it does nothing. It should be displaying an error message that the uname is less than 5 characters long. Thank you!

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function validateUsername(){
    var uname=document.getElementById("uname").value;
    if(uname<5){
        document.getElementById("errormsg").value = "wait";
    }

}
</script>

<body>
<form method=post id=regform action=jscript.html>
<table>
    <tr>    
        <td>Username</td>
        <td><input type=text name=uname id=uname onBlur="javascript:validateUsername()"/></td>
        <td><input type=hidden name=errormsg value='' id=errormsg"/></td>
    </tr>
    <tr>    
        <td>Password</td>
        <td><input type=text name=uname id=uname onBlur="javascript:validatePassword()"/></td>
        <td><input type=hidden name=errormsg value='' id=errormsg"/></td>
    </tr>
</table>
</form>

  • 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-03T06:47:17+00:00Added an answer on June 3, 2026 at 6:47 am

    try this, i hope it will help.
    You need to improve your html, put quotes around value of every attribute like type=”text” name=”uname” and all you was writing is javascript, not jquery, so you also not need to include that .js file.
    in your function validateUsername, uname holds the number of characters entered by user, and if its less then 5, then errormsg (which is id of a div) will show wait msg

    you don’t need input type=”hidden” to show error message to user, use DIV or SPAN for that

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    function validateUsername(){
        var uname=document.getElementById("uname").value.length;
    if(uname<5){
        document.getElementById("errormsg").innerHTML = "wait";
    }
    
    }
    </script>
    </head>
    <body>
    <form method="post" id="regform" action="jscript.html">
    <table>
    <tr>    
        <td>Username</td>
        <td><input type="text" name="uname" id="uname" onBlur="validateUsername()"/></td>
        <td><div id="errormsg"></div></td>
    </tr>
    <tr>    
        <td>Password</td>
        <td><input type="text" name="pass" id="pass" /></td>
        <td></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that doesn't work, can you help me? I want that
I am trying to learn javascript i have this code: x=x.replace(/^\s+|\s+$/g,); can i have
i have this simple code i just can't get it working. <html> <head> <script
I have this code. For some reason I can't get the contentpresenter to stretch
Can someone help me in django when downloading a file. I have this code:
I have this jQuery code and I'm not sure if it can be optimized
I have this code, how can I get the selected value of the @htmlDropDownList
I have this code, but i can't understand why i get this error: a=
I have this code which can display drop down in div tag of html.
I have this code ,now can anyone reply s what happens to the lock

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.