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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:37:09+00:00 2026-06-08T13:37:09+00:00

I am trying to understand why onsubmit at Javascript is using an anonymous function

  • 0

I am trying to understand why onsubmit at Javascript is using an anonymous function to get it value like that:

onsubmit = function() {return validForm();}

I know that onsubmit is taking a true or false values, but i can’t understand how does the anonymous function is necessary to get the value of true or false for the onsubmit event, like this:

onsubmit = validForm();

I will be very thankful if some one can please help me understand this, Thank you all and have a nice day.

  • 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-08T13:37:18+00:00Added an answer on June 8, 2026 at 1:37 pm

    A valid assignment would be:

    onsubmit = validForm;
    

    You’re assigning the function called validForm as the onsubmit handler. But, when you do this:

    onsubmit = validForm();
    

    You’re assigning the result of calling the function validForm to the onsubmit handler. Unless validForm is returning a function, this won’t work.

    The reason the anonymous function assignment above works is, it is assigning a function to the onsubmit handler — a function that in turn calls the validForm function when it is called.

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

Sidebar

Related Questions

Trying to understand something that I don't know how to describe because I don't
Trying to understand how to link a function that is defined in a struct,
Trying to understand why you can't use sql_variant for the value type when using
I am trying to add a file to a model using qqfile (though that
Trying to understand how EDE works by using it to generate Makefiles for a
I am trying understand how multi queries work in mysqli. But I confess that
Am trying to understand why is the instruction: pushl 0x4013ea not pushing the value
Am trying to understand the same origin policy in browsers (and also Javascript newbie)
Trying to understand an fft (Fast Fourier Transform) routine I'm using (stealing)(recycling) Input is
i'm trying to do is get all value of 10 textbox and get there

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.