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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:35:52+00:00 2026-05-30T17:35:52+00:00

I’ve read several SO posts on this issue and the one I found with

  • 0

I’ve read several SO posts on this issue and the one I found with a possible explanation was this one.
A response in that post says “Browsers do not call the onSubmit event on the form if you call submit() programmatically.”

I’m not sure if this is the operative thing affecting my form.

My code onsubmit=”return onNewUserRegistrationCheck(this);” is 100% working
— the call to onNewUserRegistrationCheck(this) is 100% occurring.

Here’s that code:

      function onNewUserRegistrationCheck(theForm)
      {

          alert("In onNewUserRegistrationCheck()");

          if(theForm.loginname.value == "<?php echo Labels::$DEFAULTLOGINEMAILLABEL ?>" 
              || theForm.password.value == "<?php echo Labels::$DEFAULTPASSWORDLABEL ?>" )
          {  
              alert("returning false now, so -- HOPEFULLY the form doesn't submit");
              return false;
          }
     }

Here’s the form:

    <form enctype="multipart/form-data" onsubmit="return onNewUserRegistrationCheck(this);"
                 class="registerFormStyles" name="registerForm" id="regform"
                 action="regTheNewUser.php" method="post">
         <input type="text" id="loginname" name="<?php  echo Labels::$USERNAMELABEL ?>"
               style="width:260px" value="<?php echo Labels::$DEFAULTLOGINEMAILLABEL ?>" />

         <input type="password" placeholder="<?php echo Labels::$DEFAULTPASSWORDLABEL ?>" 
                  id="password" name="<?php echo Labels::$PASSWORD ?>"
            style="width:220px" class="inactive" />

         <input type="hidden" name="newUserRegister" id="newUserRegisterId">

         <input type="image" name="registerButton" value="Register" class="login-button-landing" 
                    onclick="document.registerForm.submit();">
    </form>

Notice I use a type=”image” and do a programmatic submit(). According to some SO posts, the result of
a programmatic submit() like I’m doing is this: ‘Browsers do not call the onSubmit event on the form if you call submit() programmatically’

However I’m seeing 2 alert boxes when I click on my name=”registerButton” pseudo-submit button:

  alert box #1 pops up and says:  "In onNewUserRegistrationCheck()"

then….

  alert box #2 pops up and says:  "returning false now, so -- HOPEFULLY the form doesn't submit"

Those 2 alert boxes appear when I click my name=”registerButton” button on the form.
So I must (?) misunderstand what is meant in the posts I’ve read that say
‘calling submit() doesn’t fire the onsubmit event’.

The bottom line is the form is still submitted to the file “regTheNewUser.php”
even though you can see that ‘return false’ occurred because of the alert message
being seen “returning false now, so — HOPEFULLY the form doesn’t submit”

How can I stop the form being submitted without using a type=”submit” button?
I’ve proved to myself that my onsubmit=”return onNewUserRegistrationCheck(this);”
is 100% being called. I return false but the form is submitted anyway.

How can I stop the form being submitted when I find invalid form text entry
and why doesn’t ‘return false’ above STOP my form submission?

  • 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-30T17:35:53+00:00Added an answer on May 30, 2026 at 5:35 pm

    Remove

    onclick=”document.registerForm.submit();”

    !!!

    type=image IS a submit and
    document.registerForm.submit() does not trigger the onsubmit event handler!

    So the click first triggers the submission regardless, then the event handler kicks in because it is a submit button and then the form is sent to the server from the first submt

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.