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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:41:48+00:00 2026-05-18T11:41:48+00:00

I am stuck on what I thought was a simple PEBCAK error on my

  • 0

I am stuck on what I thought was a simple PEBCAK error on my part. I am trying to verify all of my functions are true before I submit a form, but cannot figure for the life of me what is wrong. Below is my javascript code:

function checknewaccount(){
if(emailvalid()&& checkname() && passwordcheck())
{
    return true;
}
else{
    return false;
}
}


function emailvalid()
{
      if(email condition)
      {
          return true;
      }
      else {
          return false;
      }
}

function checkname())
{
      if(name condition)
      {
          return true;
      }
      else {
          return false;
      }
}

function passwordcheck(){
      if(password condition)
      {
          return true;
      }
      else {
          return false;
      }
}

html below:

<form  id="newaccount" name="newaccount" method="post"  onSubmit="accountcode.php">
<input type="text" id="email" onBlur="emailvalid()"/>
<input type="text" id="username" onBlur="checkname()" />
<input type="password" id="password"  onkeyup="passwordcheck()"/>
<input type="submit" value="New" onClick="return checknewaccount()"/>
</form>

When i click “New, nothing happens, and I know the accountcode.php is not running, because nothing happens on the database end and there are no errors reported.

To sum up, my question is how checknewaccount() does not work? Does it have something to do with how I am calling them?

I am new to javascript so if I am completely off on my implementation, I apologize. Thank you very much for the help!

  • 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-05-18T11:41:49+00:00Added an answer on May 18, 2026 at 11:41 am

    you’ve got the form syntax wrong – onsubmit = the name of the js function to call, action = the url…

    <form action="accountcode.php" id="newaccount" name="newaccount" method="post"  onSubmit="return checknewaccount()">
    <input type="text" id="email" onBlur="emailvalid()"/>
    <input type="text" id="username" onBlur="checkname()" />
    <input type="password" id="password"  onkeyup="passwordcheck()"/>
    <input type="submit" value="New"/>
    </form>
    

    Fully tested code:

    <html>
        <head>
            <script type="text/javascript">
            function checknewaccount() {
                return emailvalid() && checkname() && passwordcheck();
            }
    
            function emailvalid() {
                 var emailAddress = document.getElementById('email').value;
                 return (emailAddress=='test');
            }
    
            function checkname() {
                 return true;
            }
    
            function passwordcheck() {
                 return true;
            }
    
            </script>
        </head>
        <body>
        <form action="#" onsubmit="return checknewaccount();">
            <input type="text" id="email" name="email"/>
            <input type="submit"/>
        </form>
        </body>
    </html>
    

    The form in the above code will only submit if the textbox has a value of test

    A slightly better implementation would be:

    <html>
        <head>
            <script type="text/javascript">
            function checknewaccount() {
                if(emailvalid() && checkname() && passwordcheck()) {
                    return true;
                } else {
                    document.getElementById('validation').innerHTML = 'Validation failed!';
                    return false;
                }
            }
    
            function emailvalid() {
                 var emailAddress = document.getElementById('email').value;
                 return (emailAddress=='test');
            }
    
            function checkname() {
                 return true;
            }
    
            function passwordcheck() {
                 return true;
            }
    
            </script>
        </head>
        <body>
        <div id="validation"></div>
        <form action="#" onsubmit="return checknewaccount();">
            <input type="text" id="email" name="email"/>
            <input type="submit"/>
        </form>
        </body>
    </html>
    

    As this at least tells the user the form wasn’t submitted. Even better would be to give the user a more detailed reason why but that’s beyond the scope of this question…

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

Sidebar

Related Questions

I am trying to create what I thought would be fairly simple but I'm
so here I am stuck at the simplest part (or so I thought) of
I'm stuck on what I thought was going to be a very simple task
I'm coding something I thought was simple for my programming class but I'm a
I'm sure there's a simple solution to this but it's got me stuck so
Very stuck on a problem which I thought would be pretty simple. As an
I'm trying to develop a simple 2D fighting game using OpenGL, and I'm stuck
Sounds simple but I'm stuck Table A Table B col_a col_b col_a col_c 1
Im stuck with this little project in C# but basically my problem is this:
im stuck with a problem im basically trying to create a function where 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.