Skip navigation
Currently Being Moderated

jquery validation engine and CF issue.

Aug 5, 2012 5:54 AM

Hello;

I'm working on a simple coldfusion contact form. I am trying to use a jquery plug - in with it, I have the plug in working with no problem, but it won't reload the page to allow the coldfusion to execute if all fields are valid. I'm posting my code.. can anyone help me? I think I need to add a call for the page to reload with the variables to my script.. not sure how I do that.

<link rel="stylesheet" href="scripts/validationEngine.jquery.css" type="text/css"/>

<script src="scripts/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>

<script src="scripts/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>

<script src="scripts/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>

   

<script>

        function beforeCall(form, options){

            if (window.console)

            console.log("Right before the AJAX form validation call");

            return true;

        }

           

        // Called once the server replies to the ajax form validation request

        function ajaxValidationCallback(status, form, json, options){

            if (window.console)

            console.log(status);

               

            if (status === true) {

                alert("the form is valid!");

                // uncomment these lines to submit the form to form.action

                form.validationEngine('detach');

                form.submit();

                // or you may use AJAX again to submit the data

            }

        }

           

        jQuery(document).ready(function(){

            jQuery("#formID").validationEngine({

                ajaxFormValidation: true,

                onAjaxFormComplete: ajaxValidationCallback,

            });

        });

    </script

 

and here is what sets off the coldfusion, it's all on the same page, one page mailing it and so on..

 

<cfset arrErrors = ArrayNew( 1 ) >

<cfset showForm = true>

 

<cfif structKeyExists(form, "sendcomments")>

<!--- Create an empty error string --->

 

 

<!--- we are inserting a new record --->

<cfif NOT ArrayLen( arrErrors )>

<cfmail............

 

<!--- code for cfmail goes here ----->

 

<cfoutput>

<cfform id="formID" action="#cgi.script_name#" method="post" enctype="application/x-www-form-urlencoded">

<!--- form items --->
</cfform>

<cfelse>

thank you bla bla bla
</cfif>

 

that's it without getting into the form and all of that. I have the validation working, not able to send the message. I know it's because ajax/jquery aren't reloading the page, how do I make it do that?

 

Thank you!

 
Replies
  • Currently Being Moderated
    Aug 8, 2012 9:22 AM   in reply to cfsetNewbie

    Have you already gotten this working?

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 9, 2012 5:39 AM   in reply to cfsetNewbie

    Not sure, but I will try.  I'm a little confused by your description of the problem.  You are using ajax but you want the page to reload?  I assume it is making ajax calls for server-side validation and then you want the form to submit if all fields pass.  Right?

     

    Where in your code is the process failing?

    Are you getting your javascript alert that "the form is valid!"?

    Are you seeing your console log messages and what do they tell you?

     

    Need a little more info to help diagnose.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 25, 2012 2:24 AM   in reply to cfsetNewbie

    To enable the line form.submit() to run, shouldn't that condition be if (status) instead of if (status === true)?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points