What you described is basically what I do, Rick--not because Jorn's plugin
didn't work but because many of my form fields are validated against each
other, and database interaction is required to make that decision. (e.g.,
the validity of field Y depends on the value already entered in field X.)

Below is the validate function I call onBlur from each input.  It first sets
the field's status icon to a loading spinny, then requests validation from a
CFM file, passing the value of the current field as well as the value of the
dependent criteria, which CF handles (cfswitch/cfcase) depending on which
field is passed.  The callback receives the response and shows either a
success or error icon with a descriptive error attached in a stylish little
error message balloon.

I don't know if this is the smartest method--I'm pretty new to jQuery
myself--but it has worked very well and provides the flexibility I need.

HTH,
Paul

function validateField(field, criteria){
        $("#"+field+"
img.ico").attr("src","/images/office/ico-loading.gif");
        $.get("/gateway/validate.cfm?field="+field+"&value="+$("#"+field+"
input").val()+"&criteria="+criteria,
                function(response){
                        response = eval("("+response+")");
                        showIcon(field,response.pass,response.msg);
        });     
}

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Rick Faircloth
Sent: Monday, March 12, 2007 1:55 PM
To: 'jQuery Discussion.'
Subject: [jQuery] Calling all CF'ers... et al...

Hi, guys...

I usually do all my validation using CF, by submitting
a form back to the page it's on, however, I thought I'd
give jQuery a crack at validation.  While it works fine
for the functions that are built-in, they are somewhat limited in function
and I quickly get lost in a lot of code when it comes to custom validation,
such as validating and reformatting dollar values for processing.

What I'm wondering is if I can use jQuery validation, such
as Jorn's Validation plug-in, which I've been working with,
but use calls to CF pages with CF code for validation and
formatting and returning the values to the form.

I've been using Jorn's Validation plug-in, then once all the form
entries are correct, the form values are posted out
with a $.post call to a .cfm page where calculations are run
on the form values, then the result is returned to the calling page.

What I'm getting around to asking is if I can use CF code
on separate pages and have a form field value sent to a
.cfm page "onblur" for validation using CF code, then have the resulting
value returned to the calling page after processing and/or formatting
and reinserted back into the form field.

I don't know if this makes any sense to anyone.

Let me know if it doesn't and I'll try to clarify.

For example... I use this function to calculate a mortgage payment
once all form values are valid:

        function CalculateMortgage(){

            var Params = {};

            // select all inputs of type text
            $("input:text").each(function(){
            Params[$(this).attr("name")] = $(this).val();
            }); // closes input:text function

            // "post" the form.  The Param object mimics form fields
            $.post("Mortgage_Calculation.cfm", Params, function(data){
            // this is the processing function.
         
            // append what you get back to the element with ID = Result
after clearing its contents
            $("#Result").empty().append(data);
        
            } // closes post function
            ); // closes ( after .post 
        } // closes { after CalculateMortgage = function() {


Can I functions that call .cfm pages to process and validate
individual form fields "onblur" or some other key action?

Rick



_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to