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

The Archive Base Latest Questions

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

I have been working on a JavaScript validator, but for some reason, evalid always

  • 0

I have been working on a JavaScript validator, but for some reason, evalid always returns as false even if it has passed validation… this is a bug as if evalid is false, the form doesn’t submit.

function signup_validate()
    {
        document.getElementById("email_error").innerHTML = "";
        document.getElementById("password_error").innerHTML = "";
        evalid = false;
        pvalid = false;
        email = null;
        pass = null;
        confpass = null;
        email=document.forms["signup_form"]["email"].value.replace(/^\s+|\s+$/g, '');
        atpos=email.indexOf("@");
        dotpos=email.lastIndexOf(".");
        pass=document.forms["signup_form"]["pass"].value;
        confpass=document.forms["signup_form"]["confpass"].value;
            if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length)
            {
                document.getElementById("email_error").innerHTML = "<span class='required'>Email must be valid.</span>";
            }
            else
            {
                $.post('/resources/forms/signup.php',{email: email}, function(data){
                    if(data.exists){
                        document.getElementById("email_error").innerHTML = "<span class='required'>This email is already in use.</span>";
                    }
                    else
                    {
                        evalid = true;
                    }
                }, 'JSON');
            }
            if (pass!=""&&pass!=null&&confpass!=""&&confpass!=null&&confpass==pass)
            {
                pvalid = true;
            }
            else
            {
                document.getElementById("password_error").innerHTML = "<span class='required'>Both passwords must match and cannot be left blank.</span>";
            }
            alert(evalid);
            if (evalid == true && pvalid == true)
            {
                document.getElementById("signup_form").submit();
            }
            else
            {
                return false;
            }
        }

What could I have missed?

  • 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-15T21:35:16+00:00Added an answer on June 15, 2026 at 9:35 pm

    The only moment when you set “evalid” true is inside a function that runs asynchronously. In other words, by the time you set “evalid” true the main function has already reached the end.

    You Could try to use $.ajax instead of $.post and use the parameter async:false

    Try something like this:

    $.ajax({
        type: 'POST',       
        url: '/resources/forms/signup.php',
        data: {email: email},
        success: function(response){
            //your function here
        },
        dataType:'JSON',
        async:false
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working in a JavaScript file and my content has been working
So I have been working with javascript for a website I am designing, shocker
I have been working on facebook application and you know on facebook native javascript
I have been working on a project on and off, but I haven't touched
I have been working on small site admin but have run into an odd
I have been working on a javascript application for a long time now, it
I am new to javascript and have been working overnight to see how I
I have been working on a really large html form which has a reset
I have been working on the code below for some time and cannot manage
I have been working on a perspective projection rendering demo using javascript, recently I

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.