HTML Form - javaScript - stop from submitting!

Posted on 2007-08-03
Last Modified: 2013-11-19
I have a form that onSubmit should perform some javascript functions, but I want to stop the form from actually submitting anywhere.

I've tried return false to no avail - any other ideas?

<script type="text/javaScript">
function killFunction(){
      return false;
<form name="thisInputForm" onSubmit="submitAjaxForm(this,'clientDashRecentActivity','clientDash/recentActivity.asp','activeMembersExclusions');killFunction();return false;">

Question by:trickyidiot
    LVL 11

    Expert Comment

    it should be called like:

    onSubmit = "return YourFunction()"

    and YourFunction() should return false if you don't want your form to be submitted.
    LVL 3

    Expert Comment

    Try using the attribute "action" and leave its "value" empty, like: action=" ".

    Return false should work, I think, try putting it in the form attribute using onclick, like: onclick="return false".
    LVL 11

    Accepted Solution

    call all the functions inside killFunction() like this:

    <script type="text/javaScript">
    function killFunction(n){
    return false;

    <form name="thisInputForm" onSubmit="return killFunction(this);">
    LVL 17

    Expert Comment

    Does submitAjaxForm eventually do something like: form.thisInputForm.submit()?  If there is any call to form.submit() it is likely that is what is submitting the form.  I do not know of a way to stop that javascript call from stopping the form.  However the methods listed above should be working otherwise.

    - Joe P
    LVL 44

    Expert Comment

    You will find that AJAX is the problem here, without it your script will terminate at the first return false, but with the AJAX framework, it is so complex, that it is almost impossible to debug as to where execution stops.  So to solve the problem, do not use the AJAX calls at all.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now