Form's onsubmit is called but action is not performed

Posted on 2009-12-26
Last Modified: 2013-12-25

I have a coldfusion page FileRequest.cfm. On this page, there is form in which onsubmit method is specified  - which is formatreg(). The Form has  ACTION="<CFOUTPUT>#APPLICATION.ServerURL#</CFOUTPUT>/file/fileRequest.cfm"
which is calling the same page i.e. filerequest.cfm

What happens is when I click on submit button, this onsubmit method(formatreg  ) is called but the action is never performed i.e.  "<CFOUTPUT>#APPLICATION.ServerURL#</CFOUTPUT>/file/fileRequest.cfm"
is never called, so the page just stays there and does nothing....

This happens on just one client's machine. I donot know what browser settings on his machine are causing this. Is it becos of browser settings or something else. Client is using IE 6  and Coldfusion version is 7 .

I read @ problems with onsubmit method on It says that since its javascript it does give some problems and it says to check cgi script. but since this does not happen on all the machines, i donot think its this issuse...

I have pasted the code below...

Pl help...


<CFIF #parameterexists(vadd)# is "Yes">
    <CFIF #filetype# is "F" AND #IsDate(enddate)# is "No">
                  <SCRIPT LANGUAGE="JavaScript">
            alert("Your end date (#enddate#) is not a valid date.\nPlease enter with a format of MM/DD/YYYY.")

    <CFIF #len(filetext)# LT 1>
                 <SCRIPT LANGUAGE="JavaScript">
            alert("You must provide text \nfor your file.")

  <CFLOCATION URL="fileThanks.cfm?A=#Variable.Action#">

function formatReg(form)
   if (form.Email.value.length ==0)
           alert("Please provide your e-mail address");
           return false;


<script language="javascript" >
  function selfileType_SetDisplay ()
     var trEndDate = document.all.item("trEndDate");
     var selfileType = document.all.item("filetype");

         if (selfileType.value == "F")
         return true;


<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" onload="selfileType_SetDisplay()">

<p align="center"><font face="Arial" color="#000080" size="2">Please make sure that you fill out
all of the fields in </font><font face="Arial" color="#FF0000" size="2">red</font><font
face="Arial" color="#000080">.</font></p>
<FORM METHOD="post" onSubmit="return formatReg(this)" ACTION="<CFOUTPUT>#APPLICATION.ServerURL#</CFOUTPUT>/file/fileRequest.cfm">
      <table align="Center" border="4" cellpadding="6" cellspacing="2" width="90%">

      <TR><TD COLSPAN="2" ALIGN="Center" BGCOLOR="#000091">
                <FONT FACE="Arial" COLOR="#FFFFFF" SIZE="-1">

                 <TD BGCOLOR="EEEEEE">First Name</TD>
                 <td> <INPUT TYPE="text" NAME="firstname" SIZE="25" MAXSIZE="" VALUE=""><br></TD>

         <TD BGCOLOR="EEEEEE">Last Name</TD>
         <td> <INPUT TYPE="text" NAME="lastname" SIZE="25" MAXSIZE="" VALUE=""><br></TD>

         <TD BGCOLOR="EEEEEE">Phone:</TD>
                 <td><INPUT TYPE="text" NAME="Phone" SIZE="25" MAXSIZE="" VALUE=""><br></TD>

        <TD BGCOLOR="EEEEEE"><font face="Arial" color="#FF0000" size="2">E-Mail</TD>
        <td> <INPUT TYPE="text" NAME="Email" SIZE="25" MAXSIZE="" VALUE=""> </TD>

                <TD BGCOLOR="EEEEEE"> <font face="Arial" color="#FF0000" size="2">file Type:</TD>
        <TD><SELECT ID="selfileType" size="1" name="filetype"  onchange="javascript:selfileType_SetDisplay ()">
             <option value="" selected >--Select Type--</option>
             <option value="G"  >General file</option>
             <option value="I"  >Incorrect File</option>
             <option value="M"  >Missing Info</option>
             <option value="F"  >Other Notes</option>

   <TR id="trEndDate" style="display:none">
        <td  BGCOLOR="EEEEEE"><font face="Arial" color="#FF0000" size="2">Other Notes End Date:</td>
        <td> <input type="text" size="10" maxlength="10" name="enddate" value=""> Format: MM/DD/YYYY</td>

             <td  BGCOLOR="EEEEEE"><font face="Arial" color="#FF0000" size="2">file Text:</td>
                 <TD>  <TEXTAREA NAME="filetext" ROWS=6 COLS=50 wrap=hard></TEXTAREA> </TD>

             <td COLSPAN="2" ALIGN="Center">
                      <input type="submit" value="Submit" NAME="vadd">
                      <input type="button" value=" Cancel " onclick="window.close()">


Question by:at999
    LVL 10

    Expert Comment

    You will probably have more luck if you post this in the following zone:
    Internet > Web Development > Web > Coldfusion Studio

    Author Comment

    thanks tdlewis for the reply,
    but i think this is issue with cgi/IIS (I donot know anything in CGI)

    But I read @ problems with onsubmit method(onsubmit method is called when the form is submitted) on It says that since its javascript it does give some problems and it says to check cgi script.
    thats why i placed in CGI section
    LVL 10

    Accepted Solution

    The action of your form is .../fileRequest.cfm so the "CGI" that is being executed is a ColdFusion file.

    As for your onsubmit method, it is called between the time the "Submit" button is clicked and the form is sent to the server. Its purpose is to determine whether the form should be sent to the server or not. If formatReg returns false then the browser will not send the form to the server; in the code you supplied, the only thing that would prevent the form from being submitted is for form.Email.value.length == 0.

    Assuming that the email field is not blank, the data is sent to the server. In that case, you need to look at fileRequest.cfm and determine why it is not doing what you expect.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Mobile App Development with PhoneGap

    PhoneGap can help you leverage your already existing HTML5, JavaScript, and CSS skills in order to create and deploy cross-platform mobile apps.This program comprehensively covers HTML5 mobile app development from top to bottom.

    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Read about why website design really matters in today's demanding market.
    The viewer will learn how to dynamically set the form action using jQuery.
    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 …

    737 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

    18 Experts available now in Live!

    Get 1:1 Help Now