Hi, all...

Here's the function: (Thanks, Dan...)

<script type="text/javascript">

        function superCoolValidator(value,element,params) {
                if(isNaN(parseInt(value.replace(/[\$\,\.]/,"")))){
                        return false;
                        }else{
                        return true;
                }
        }
        
</script>


Here's the addMethod line:

        $.validator.addMethod("superCoolValidator", superCoolValidator,
"Your input is not super cool!");


And here's the INPUT:

                       <INPUT id="Principal"
                        Test="superCoolValidator:true"
                      Name="Principal"
                           Type="Text"
        
Value="#Ceiling(Trim(Get_Property_Details.Sale_Price))#"
                        Size="14"
                          Class="TextInput01">


I get no errors from Firebug, but the "superCoolValidator" (Dan's name :o)
doesn't
seem to have any effect on the input.  The form gets submitted by this
input:

<INPUT ID="Calculate" Value=" Calculate " Type="Submit">


and the submission is caught by the submitHandler in this Validator
function:

    $().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: "blur",
                
        rules: {
        
            //Principal: {required: true,
                         //digits: 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(){

             CalculateMortgage();

      }

    })
    });
                

One last bit... the "CalculateMortgage" function that is called by the
submitHandler is this:

        function CalculateMortgage(){

            var Params = {};

            $("input:text").each(function(){
            Params[$(this).attr("name")] = $(this).val();
            });

            $.post("Mortgage_Calculation.cfm", Params, function(data){

        $("#Result").empty().append(data);
        
            }
            );
        }


Can anyone make some sense of what's going on and what I need to do to get
the
"superCoolValidator" to have an effect on the "Principal" input?

Thanks!

Rick


Reply via email to