Hi, all... (and perhaps you're around, Jorn?)
One of the things that confuses me most about JS
is the bracketing that has to occur.
Jorn, I've tried to place the submitHandler in my code
and I don't know if I've done that correctly, but I do know
that I'm getting an error in Firebug:
"missing { before function body"
$("#MC_Form").validate({\n
Before I moved my code that was handling the mortgage calculation
inside the validation code, I wasn't getting this error.
I'm sure it's because I'm missing a bracket somewhere (as it says),
but I'm not sure how to correct my code.
Can someone review the code below for proper bracketing (or anything
else you may notice) and tell me how to correct it?
Thanks for the help!
Rick
<script type="text/javascript">
$.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(){
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 input:text function
} // closes the submitHandler function
}) // closes the ) before the .validate bracket?
}); // closes the .validate bracket
</script>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/