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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:36:03+00:00 2026-06-07T05:36:03+00:00

with inline event listeners I mean HTML elements attributes for event registration like onsubmit/onreset

  • 0

with inline event listeners I mean HTML elements attributes for event registration like onsubmit/onreset attributes rather than dom node properties for registering event.

I’m asking because when I register an event handler that returns false to onsubmit/onreset attributes of a form, by submitting/reseting the submit/reset process is performed.

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>New Web Project</title>

        <script type="text/javascript">
            function f()
            {
               return false;
            }

        </script>

    </head>
    <body>
        <form action="" id = "form" onsubmit = "f()" onreset = "f()">
             <input type="text">
             <input type = "submit" value = "submit">
             <input type = "reset" value = "reset">
        </form>
    </body>
</html>
  • 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-07T05:36:05+00:00Added an answer on June 7, 2026 at 5:36 am

    When you provide event handlers via the HTML attributes, the string you provide creates a function which is called by the browser when the event occurs.

    So in your example, the onsubmit and onreset attributes create two functions equivalent to:

    function() {
      f();
    }
    

    Because that anonymous function doesn’t return false, the submit and reset events aren’t blocked. If that is what you want to do, you can do one of the following.

    To always block default handling:

    onsubmit="f(); return false;" onreset="f(); return false;"
    

    To conditionally block default handling (and a little bit better code style, IMO):

    onsubmit="return f();" onreset="return f();"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to migrate from using inline event triggers to using event listeners using
Inline Event Registration works correctly if I use code similar to onerror=function(this) // in
I'm trying to get a list of all inline event tags from an HTML
I'd like to use JavaScript only (no jQuery) to replace an inline onmenuclick event
The problem: making a very simple style switcher with js (without inline event handling).
I'm using scriptaculous Builder to generate some DOM elements dynamically, and one of them
Okay so, I'm wondering how to unbind an inline onclick event in jQuery. You'd
Jquery UI Function: // Datepicker $('#datepicker').datepicker({ inline: true }); Event: <input name=txtLogistics_ExecutionDate type=text id=datepicker
I have a simple button in HTML like this: <input type='button' id='btnPrint' value='Print' onclick=changeStylesheet();
I have been using jQuery prettyPhoto plugin to show inline html content. This content

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.