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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:37:22+00:00 2026-05-19T13:37:22+00:00

I’ve been struggling to make this work for quite some time. I have the

  • 0

I’ve been struggling to make this work for quite some time. I have the following code:

$(document).ready(function (event) {
    $('form').submit(function (event) {
    ...
    });
});

I’ve found in most of the places, including on the jQuery site, that this will prevent the form from being submitted:

return false;

It doesn’t.

Next I’ve read all related question and answers on this site and tried them all out.
In Chrome and Firefox this works:

event.preventDefault();

In IE8 it doesn’t. I’ve read that IE doesn’t support this and we should use this:

event.returnValue = false;

Although several people confirm that it worked for them (e.g. event.preventDefault() function not working in IE. Any help?), it doesn’t for me. I’m not sure why though. I have a form with a submit button, nothing special, but, even if I put only this piece of code, the form is still submitted:

$(document).ready(function (event) {
    $('form').submit(function (event) {
        event.returnValue = false;
    });
});

Any ideas?

One last thing: I’ve read that we should test this first before calling preventDefault():

if (event.preventDefault) { event.preventDefault(); }

But in IE8, event.preventDefault exists and no error is thrown. How can that be if it’s unsupported by IE?

Update 1: I’ve tried a simplified version with the following code:

CancelSubmitTest.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CancelSubmitTest.aspx.cs" Inherits="HtmlEditor.CancelSubmitTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="Scripts/CancelSubmit.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="SaveButton" runat="server"
            Text="Save" OnClick="SaveButtonClick" CausesValidation="true" ValidationGroup="SomeValidationGroup" />
    </div>
    </form>
</body>
</html>

CancelSubmitTest.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HtmlEditor
{
    public partial class CancelSubmitTest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void SaveButtonClick(object sender, EventArgs e)
        {

        }
    }
}

CancelSubmit.js

$(document).ready(function (event) {
    $('form').submit(function (event) {
        event.returnValue = false;
    });
});

It’s a pretty straight-forward example. The JavaScript code is executed but the form is still submitted, although I set event.returnValue to false. What am I doing wrong?

Update 2: I’ve changed the javascript code in the simplified project as follows:

$(document).ready(function (event) {
    $('form').submit(function (event) {
        return false;
    });
});

It works in IE but I still have to figure out why it doesn’t work in my application. Thanks to everyone for your 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-19T13:37:23+00:00Added an answer on May 19, 2026 at 1:37 pm
    1. It does work: http://jsfiddle.net/AEC2U/
    2. The problem is somewhere else in your code.
    3. Post more code/stripped down example where it doesn’t work.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
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,
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.