• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

jquery validation engine and CF issue.

Community Beginner ,
Aug 05, 2012 Aug 05, 2012

Copy link to clipboard

Copied

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!

Views

3.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 08, 2012 Aug 08, 2012

Copy link to clipboard

Copied

Have you already gotten this working?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 08, 2012 Aug 08, 2012

Copy link to clipboard

Copied

no not yet.. still pondering it. Can you help?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 09, 2012 Aug 09, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 25, 2012 Oct 25, 2012

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation