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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:55:13+00:00 2026-05-20T11:55:13+00:00

The question is pretty self-explanatory. I don’t understand what the return is doing in

  • 0

The question is pretty self-explanatory. I don’t understand what the return is doing in the following code:

<form onsubmit="return somefunction()">
  • 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-20T11:55:14+00:00Added an answer on May 20, 2026 at 11:55 am

    You need the return so the true/false gets passed up to the form’s submit event (which looks for this and prevents submission if it gets a false).

    Lets look at some standard JS:

    function testReturn() { return false; }
    

    If you just call that within any other code (be it an onclick handler or in JS elsewhere) it will get back false, but you need to do something with that value.

    ...
    testReturn()
    ...
    

    In that example the return value is coming back, but nothing is happening with it. You’re basically saying execute this function, and I don’t care what it returns. In contrast if you do this:

    ...
    var wasSuccessful = testReturn();
    ...
    

    then you’ve done something with the return value.

    The same applies to onclick handlers. If you just call the function without the return in the onsubmit, then you’re saying “execute this, but don’t prevent the event if it return false.” It’s a way of saying execute this code when the form is submitted, but don’t let it stop the event.

    Once you add the return, you’re saying that what you’re calling should determine if the event (submit) should continue.

    This logic applies to many of the onXXXX events in HTML (onclick, onsubmit, onfocus, etc).

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

Sidebar

Related Questions

I think the question itself is pretty self-explanatory. The code is given below -
I think the question is pretty self explanatory. Anyone done this before? UPDATE :
Pretty self explanatory question. Is there any reason to use one or the other?
The question's pretty self-explanatory really. I know vaguely about vectors in maths, but I
diagram http://img526.imageshack.us/img526/2506/picture1lx.jpg The question is pretty self-explanatory. Is there a technical name for that
The question is pretty much self-explanatory. I Googled many sites, many methods, tried many
The title of this question should be pretty self explanatory. I am making an
Question is pretty much self-explanatory. I'm working with naming USB drives if that matters.
The question is pretty much self-explanatory.
Well my question is pretty self-explanatory. I have a class and I want to

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.