2 Replies Latest reply on Jul 30, 2014 9:32 AM by BKBK

    CFFORM onSubmit script works in FF but not in IE

    Gakusei Level 1

      I've got a CFFORM that has an onSubmit additional javascript for  form validation, and while it works in FF, it passes right through in IE and ends up erroring because the mandatory fields aren't there...

       

      the CFFORM call looks like this

       

      <cfform name="add_project" method="post" action="xxxxxxx.cfm?view=admin-add-process&entity=project" enctype="multipart/form-data" onsubmit="return checkReq();">

       

      and the function looks like

       

      <script language="javascript">

      function checkReq() {

      var valid = true;

      var errMsg = '';

      if (document.add_project.projectreviewer_emails.value.trim() == '') {

      ...

      } else {

      ...

      }

      ...

      </script>

       

      Any ideas?

       

      Thanks in advance,

       

      bw

        • 1. Re: CFFORM onSubmit script works in FF but not in IE
          duncancumming Level 3

          What does the input field projectreviewer_emails look like in your HTML?

           

          What do you get if you do

          • console.log(document.add_project.projectreviewer_emails.value);
          • console.log(document.add_project.projectreviewer_emails);
          • console.log(document.add_project);

           

          PS: the language attribute on <script> has been deprecated since 1999, change it to

          <script type="text/javascript">

          or even just

          <script>

          • 2. Re: CFFORM onSubmit script works in FF but not in IE
            BKBK Adobe Community Professional & MVP

            There is some doubt regarding the universality of Javascript's trim function among browsers. Is it vital here?  If you leave it out, your code will work across all browsers. Something along the lines of:

             

            <script type="text/javascript">

            function checkReq() {

                var valid = true;

                var errMsg = '';

                var projectReviewerEmails = document.forms["add_project"]["projectreviewer_emails"].value;

                if (projectReviewerEmails == '') {

                    // no no no no no

                    return !valid;

                } else {

                    // yeah yeah yeah yeah yeah

                    return valid;

                }

            }

            </script>

             

            <cfform name="add_project" method="post" action="test.cfm?view=admin-add-process&entity=project" enctype="multipart/form-data" onsubmit="return checkReq();">

            <cfinput type="file" name="projectreviewer_emails" >

            <cfinput type="submit" name="sbmt" value="Submit">

            </cfform>

            1 person found this helpful