$(document).ready(function(){

    // Toggle "other" text field
    $("#other-description-container").hide();
    $('#designation').change(function() {
          $('#other-description-container').toggle($(this).val() == 'Other');
    }).change();
    
    // Validate the input
    $("#regform").validate({
        rules: {
            amount: {
                required: true,
                digits : true
            },
            description: "required",
            other_description: { 
                required: "#other:selected",
            }
        },
        messages: {
            amount: "Please enter a valid amount",
            description: "Please select a designation",
            other_description: "Please enter a description"
        }
    });
});

