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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:06:04+00:00 2026-06-03T00:06:04+00:00

resolved my javascript issue. Sorry it was mainly my fault as i copied and

  • 0

resolved my javascript issue. Sorry it was mainly my fault as i copied and pasted my code instead of rewriting it out again. Strange thing is that it doesn’t seem to pass the variables from the form to the process page as i have echo’d the SQL statement back out. This form did work previously to the java script all i added in was Post Code: for each row and even after deleting the javascript it still doesn’t work :S
Sorry deadline tomorrow and im panicing.

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

                var firstName = document.getElementById('firstName').value;
                if(firstName.length <3)
                {
                    alert("Forname is to short");
                    return false;
                }

                var lastName = document.getElementById('lastName').value;
                if (lastName.length <3)
                {
                    alert("Surname is to short");
                    return false;
                }

                var address = document.getElementById('address').value;
                if (address.length <8)
                {
                    alert("Address is to short");
                    return false;
                }

                var town = document.getElementById('town').value;
                if (town.length <3)
                {
                    alert ("Town is to short");
                    return false;
                }

                var postCode = document.getElementById('postCode').value;
                if (postCode.length <6)
                {
                    alert ("Invalid Post Code");
                    return false;
                }
                else if (postCode.length>8)
                {
                    alert("Invalid Post Code");
                    return false;
                }


                var cardType = document.getElementById('cardType').value;
                if (cardType.length <3)
                {
                    alert ("Please enter a valid card type");
                    return false;
                }

                var password = document.getElementById('password').value;
                if (password.length <6)
                {
                    alert ("You password must be between 6-12 characters");
                    return false;
                }
                else if(password.length>12)
                {
                    alert ("Your password must be between 6-12 characters");
                    return false;
                }
                else
                {
                    return true;
                }


            }

            function checkUsername()
            {
                var username = document.getElementById('username').value;
                var element = document.getElementById('username1');
                if(username.length < 5)
                {
                    element.innerHTML = "Username is to short";
                    element.style.color = "red";
                }
                else if (username.length >16)
                {
                    element.innerHTML = "Username is to long";
                    element.style.color = "red";
                }
                else
                {
                    element.innerHTML = "Username";
                    element.style.color = "green";
                }
            }
            function checkFname()
            {
                var firstName = document.getElementById('firstName').value;
                var element = document.getElementById('firstname1');
                if(firstName.length < 3)
                {
                    element.innerHTML = "Forname is to short";
                    element.style.color = "red";
                }
                else
                {
                    element.innerHTML = "Forname";
                    element.style.color = "green";
                }
            }
            function checkLname()
            {
                var lastName = document.getElementById('lastName').value;
                var element = document.getElementById('surname1');
                if(lastName.length < 3)
                {
                    element.innerHTML = "Surname is to short";
                    element.style.color = "red";
                }
                else
                {
                    element.innerHTML = "Surname";
                    element.style.color = "green";
                }
            }
            function checkAddress()
            {
                var address = document.getElementById('address').value;
                var element = document.getElementById('address1');
                if(address.length < 8)
                {
                    element.innerHTML = "Address is to short";
                    element.style.color = "red";
                }
                else
                {
                    element.innerHTML = "Address";
                    element.style.color = "green";
                }
            }
            function checkTown()
            {
                var town = document.getElementById('town').value;
                var element = document.getElementById('town1');
                if(town.length < 3)
                {
                    element.innerHTML = "Town is to short";
                    element.style.color = "red";
                }
                else
                {
                    element.innerHTML = "Town";
                    element.style.color = "green";
                }
            }
            function checkPostCode()
            {
                var postCode = document.getElementById('postCode').value;
                var element = document.getElementById('postcode1');
                if(postCode.length < 6)
                {
                    element.innerHTML = "Post code is to short";
                    element.style.color = "red";
                }
                else if (postCode.length>8)
                {
                    element.innerHTML = "Post Code To Long";
                    element.style.color = "red";
                }
                else
                {
                    element.innerHTML = "Post Code";
                    element.style.color = "green";
                }
            }

                function checkCard()
                {
                    var cardType = document.getElementById('cardType').value;
                    var element = document.getElementById('card1');
                    if(cardType.length < 3)
                    {
                        element.innerHTML = "Card is to short";
                        element.style.color = "red";
                    }
                    else
                    {
                    element.innerHTML = "Card Type";
                    element.style.color = "green";
                    }
                }
                function checkPassword()
            {
                var password = document.getElementById('password').value;
                var element = document.getElementById('password1');
                if(password.length < 6)
                {
                    element.innerHTML = "Password is to short";
                    element.style.color = "red";
                }
                else if (password.length>16)
                {
                    element.innerHTML = "Password is to long";
                    element.style.color = "red";
                }
                else
                {
                    element.innerHTML = "Password";
                    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" >

    <table> 
    <tr><td><label id="username1">Username:</label></td><td><input id="username" type="text" size="16" onBlur='checkUsername();'/></td></tr>
    <tr><td><label id="firstname1">Forename:</label></td><td><input id="firstName" type="text" size="20" onBlur="checkFname();" /></td></tr>
    <tr><td><label id="surname1">Surname:</label></td><td><input id="lastName" type="text" size="30" onBlur="checkLname();" /></td></tr>
    <tr><td><label id="address1">Address:</label></td><td><input id="address" type="text" size="50" onBlur="checkAddress();" /></td></tr>
    <tr><td></td><td><input id="address2" type="text" size="50" onBlur="" /></td></tr>
    <tr><td><label id="town1">Town:</label></td><td><input id="town" type="text" size="50" onBlur="checkTown();" /></td></tr>
    <tr><td><label id="postcode1">Post Code:</label></td><td> <input type="text" id="postCode" size="8" onBlur="checkPostCode();" /></td></tr>
    <tr><td><label id="contact1">Contact No:</label></td><td> <input type="number" id="contact" size="12" onBlur="checkContactNo();" /></td></tr>
    <tr><td>Card Number:</td><td><input type="number" id="cardNo1" size="4" /> - <input type="number" id="cardNo2" size="4" /> - <input type="number" id="cardNo3" size="4" /> - <input type="number" id="cardNo4" size="4" /></td></tr>
    <tr><td><label id="card1">Card Type</label></td><td> <input type="text" id="cardType" size="8" onBlur="checkCard();" /></td></tr>
    <tr><td>Email Address:</td><td><input id="emailAddress" type="text" size="50" /></td></tr>
    <tr><td><label id="password1">Password:</label></td><td><input id="password" type="password" size="16" onBlur="checkPassword();" /></td></tr>
    <tr><td><label id="terms1">Accept Terms & Conditions:</label></td><td><input type="checkbox" id="termsConditions" value="yes" onBlur="checkTerms();" /></td></tr>
    <tr><td><input type="reset" id="resetForm" value="Reset" id="resetForm" /></td><td><input type="submit" id="submitUser" value="Submit" id="submitUser" onSubmit='return checkForm();' /></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-03T00:06:05+00:00Added an answer on June 3, 2026 at 12:06 am

    As others said, check your syntax. In checkform(), it should be

    else if (username.length > 16)) instead of < 16
    

    and in checkUsername() you spelled length wrong.

    But your main problem is in your returns. In checkform() you should only put return true at the end when everything has been validated, or else the function just exit after the first validation.

    You could also refactor all of this. You’ve got plenty of function that do almost the same thing. If you make one function that take minimum characters, maximum characters and the control to validate in parameters, you could do all of your code in 20 to 30 lines.

    Plus, it seems like you copy-pasted some of your functions without changing the name of the variables or the targeted control. In fact, you assign Username as a variable in every function, but change the name in the condition, meaning you use an unassign variable.

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

Sidebar

Related Questions

I resolved this issue myself. It turns out that the activation framework requires some
RESOLVED I found the issue and am sorry to say it is quite idiotic.
UPDATE: I have somewhat resolved the issue. Just in case if anyone runs in
Update: Issue Resolved A colleague of mine was changing a cell during Workbook_BeforeSave() without
I am facing issue with the following Json reponse object in the javascript eval
This question was asked here but the issue wasn't resolved. Please see this jsfiddle
EDIT: Sorry Guys, This has been resolved The comment to check the inline style
In my javascript file, I have a code snippet like: $('<form action=process.php method=POST>' +
I am developing a small web application optimized for iPad (using mainly javascript &
How would I keep javascript and php code from being entered into a form

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.