Ok... got rid of the "onClick" part of the INPUT...

Jake, used your submitHandler...

Made the changes to the rest of the code you suggested, Aaron.

Now, I don't get any errors, and the field validation is working,
but when I click the Calculate button, I don't get a result returned... in this
case that would be the payment.

The MortgageCalculator code in the new version is repeated in the beginning
of the script, then within the submitHandler... is this correct?

What adjustments should I make from here?

Thanks for the help!

Rick

Here's the new version of the code:

<script type="text/javascript">

// Define CalculateMortgage in the global scope so that it is always accessible 
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() {

$.validator.defaults.debug = true;
$().ready(function() {
    // validate Mortgage_Calculation_Form form fields on keyup
    $("#MC_Form").validate({
        
                errorPlacement: function(error, element) {

                if(element.attr('id') == "Principal") {
                        error.appendTo("#principal_error");
                }
                
                else
                 
                if(element.attr('id') == "Interest") {
                        error.appendTo("#interest_error");
                        }
                        
            else
                        
                if(element.attr('id') == "Years") {
                        error.appendTo("#years_error");
                        }
                        
        },//closes errorPlacement function

                    focusInvalid: "false",
                        
                        event: "keyup",
                        
                        rules: {
                        
                                Principal: {required: true,
                                            number: true},
                                Interest: {required: true,
                                           number: true},
                                Years: {required: true,
                                        number: true}
                                        },

                        messages: {
                        
                                Principal: {required: "Please enter the 
Principal.",
                                            number: "Please enter a number.  
Format: 255000 (No $ or , )"},
                                Interest: {required: "Please enter the Interest 
Rate.",
                                           number: "Please enter a number."},
                                Years: {required: "Please enter the Years.",
                                        number: "Please enter a number."}
                                        },
                
submitHandler:function(){
        varParams={};
        $("input:text").each(function(){
                Params[$(this).attr("name")]=$(this).val();
        })
        $.post("Mortgage_Calculation.cfm",Params,function(data){
                $("#Result").empty().append(data);
        })
}

    }) // closes the ) before the .validate bracket? 
}); // closes the .validate bracket

                
</script>





_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to