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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:38:47+00:00 2026-06-01T03:38:47+00:00

I have created a signup page on my site, but the javascript validation function

  • 0

I have created a “signup” page on my site, but the javascript validation function does not seem to call when the “onsubmit” event is fired. I have already read the posts on this site regarding a similar issue, but their problem seems to be that they forgot to return a boolean value indicating to go ahead and perform the action. Note that this page is “included” in another page with the php function “include”.

<script type="text/javascript">
    function validateForm()  {
        //alert();
        var display = document.getElementById('error');
        var usernameValue = document.getElementById('username').value;
        var passwordValue = document.getElementById('password').value;
        var rptPasswordValue = document.getElementById('rptPassword').value;
        var emailValue = document.getElementById('email').value;
        var aliasValue = document.getElementById('alias').value;

        if (usernameValue != '' && passwordValue != '' && rptPasswordValue != '' && emailValue != '' && aliasValue != '')  {
            if (passwordValue == rptPasswordValue)  {
                if (usernameValue.length > 32 || aliasValue.length > 32)  {
                    displayError("Username or password is too long (Both fields must contain 32 characters or less)");
                } else {
                    if (passwordValue.length > 32 || passwordValue.length < 4)  {
                        displayError("Password must be between 4 and 32 characters in length.");
                    } else {
                        if (emailValue.indexOf('@') == -1 || emailValue.length > 64 || emailValue.length < 6)  {
                            displayError("Please make sure you have entered a valid email. (Emails must be between 6 and 64 characters in length)");
                        } else {
                            if (aliasValue < 3 || aliasValue > 32)  {
                                displayError("Your alias must be between 3 and 32 characters in length.");
                            } else {
                                return true;
                            }
                        }
                    }
                }
            } else {
                displayError("Please make sure both passwords match.");
            }
        } else {
            displayError("Please make sure each field contains a value.");
        }

        return false;
    }

    function displayError(var msg)  {
        document.getElementById('error').innerHTML = msg;
    }
</script>
<h1>Sign Up</h1>
<p>All fields must be filled out in order for an account to be created.</p>
<form onsubmit="return validateForm();" action="register.php" method="post">
    <table>
        <tr>
            <td>
                <p class="txtLabel">Username:</p>
            </td>
            <td>
                <input type="text" class="defaultTxt" tabindex="0"  id="username" name='username'>
            </td>
            <td>
                <p class="txtLabel">Email Address:</p>
            </td>
            <td>
                <input type="text" class="defaultTxt" tabindex="1"  id="email" name='email'>
            </td>
        </tr>
        <tr>
            <td>
                <p class="txtLabel">Password:</p>
            </td>
            <td>
                <input type="password" class="defaultTxt" tabindex="2"  id="password" name='password'>
            </td>
        </tr>
        <tr>
            <td>
                <p class="txtLabel">Repeat Password:</p>
            </td>
            <td>
                <input type="password" class="defaultTxt" tabindex="2"  id="rptPassword" name='rptPassword'>
            </td>
        </tr>
        <tr>
            <td>
                <p class="txtLabel">Nickname/Alias:</p>
            </td>
            <td>
                <input type="text" class="defaultTxt" tabindex="4"  id="alias" name='alias'>
            </td>
        </tr>
    </table>
    <p><b id='error' style='color: red'></b></p><br />
    <input type="submit" value='' name='submit' class="submitBtn">
</form>

Note that in the validateForm function the alert was used to test if the function was called at all, it isn’t.

Any ideas?

  • 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-01T03:38:49+00:00Added an answer on June 1, 2026 at 3:38 am
    function displayError(var msg)  {
            document.getElementById('error').innerHTML = msg;
        }
    

    Replace it with

    function displayError(msg)  {
            document.getElementById('error').innerHTML = msg;
        }
    

    In your java-script function you cant write like function displayError(var msg).

    Good luck.

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

Sidebar

Related Questions

I have created a WebView and opened up a web page in it that
I have created a button programmatically and I want to fire event to go
I have a signup form that needs to be loaded for every page of
I have created a signup form for secure zone in Business Catalyst. I want
I have created a sign-up and login for my website and all validation works
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a template for Visual Studio 2008 and it currently shows up
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a PHP-script to update a web server that is live inside
I have created a UserControl that has a ListView in it. The ListView is

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.