javascriptjquerysyntax-errorjquery-validation-engine

SyntaxError-Unexpected End of Input


I'm a newbie. Just coded a simple loan approval application using Javascript with Jquery and Jquery Validation plugins. I'm getting a SyntaxError. - I've matched the beginning and end parens, curly brackets, semicolons and commas and don't understand why its not working. - I've tried different variations and keep getting the error (it points to different code lines with each change). - When I comment out the jQuery Validation code it works so the issue must be with the jQuery Validation code.

Below is code. Currently getting SyntaxError on line 61 which is the last line reflecting --> });

// JavaScript Document // DIAMOND LENDING BANK LOAN APPLICATION

$(document).ready(function() {
    $("#submit").click(function() {
    var salary =  $("#salary").val();   // get salary
    var creditScore = $("#creditScore").val(); // get creditScore
    var monthsJob = $("#monthsJob").val(); // get months at job

    if  (salary >= 40000 && creditScore >= 600) {
        $("#decision").html("Your loan is approved!")
    }
    else if (salary >= 40000 && monthsJob >= 12) {
        $("#decision").html("Your loan is approved!")
    }
    else if (creditScore >= 600 && monthsJob >= 12) {
        $("#decision").html("Your loan is approved!")
    }
    else {
        $("#decision").html("Your loan is declined.")
    };
    return false;
    }); // closes submit.click  

    //     J Q U E R Y    V A L I D A T O R
    $("#loanApp").validate({
        rules: {
            salary: {
            required: true,
            rangelength: [4, 10],
            number: true
            },
            creditScore: {
            required: true,
            rangelength: [3, 3],
            number: true
            },
            monthsJob: {
            required: true,
            rangelength: [1, 3], 
            number: true
            },  
            messages: {
            salary: {
            required: "Please enter your salary.",
            rangelength: "Enter at least 4 numbers and up to 10.",
            number: "Enter numbers only."
            },
            creditScore: {
            required: "Please enter your Credit Score.",
            rangelength: "Credit Scores are 3 numbers long.",
            number: "Enter numbers only."
            },
            monthsJob: {
            required: "Please enter your months at current job.",
            rangelength: "Enter at least 1 number and up to 3.",
            number: "Enter numbers only."
            }
        } 
    }
});

Solution

  • You lack another }); at the very end for your $(document).ready(.... The current one is for the $(#loanApp).validate(...