onsubmit not firing in IE

javascript Australia
  • 13 years ago
    I am having trouble with a form validation in IE. No matter which way I reword the syntax (depends which site you read) IE 6/7 will not interrupt the form submission when a validation is failed. Here's a url to a testpage I created to demonstrate. It only one field and if this field is left blank the submission is failed and thus cancelled atleast in FF/Opera.

    The code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title></title>
    <script type="application/javascript">
    <!--
        function validate()
        {   
            if(document.getElementById("mFName").value=="")
            {
                return false;
            }
            else
            {
                 return true;
            }
        }
    //-->
    </script>
    </head>
    <body>
    <form name="memberAppForm" id="memberAppForm" action="test.php" onSubmit="return validate();" method="post" target="_self">
    <input name="mFName" id="mFName" type="text" size="32"><input name="reset" id="reset" type="reset" value="reset">&nbsp;
              <input name="submit" id="submit" type="submit" value="submit">
    </form>
    </body>
    </html>

    The php:
    <?php
        echo ("The value of mFName is ".$_POST['mFName']);
    ?>

    Why won't IE cancel the submission and NOT go to the next page????
     








































Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is anticipated with distaste, performed with reluctance, and bragged about forever.” - Dan Kaminsky