$().ready(function() {
    // validate signup form on keyup and submit
    $("#campsForm").validate({
        rules: {
            camp_venue: "required",
            part_name_1: "required",
            contact_address_1: "required",
            contact_address_3: "required",
            // contact_address_4: "required",
            contact_postcode: "required",
            tandc: "required",
            contact_tel: {
                required: true,
                telephone: true
            },
            contact_mob: {
                telephone: true
            },
            part_username: {
                required: true,
                remote:"usersCoach.php"
            },
            contact_email: {
                required: true,
                email: true
            },
            account_password: {
                required: true,
                minlength: 6
            },
            account_password_2: {
                required: true,
                equalTo: "#account_password"
            }
        },
        messages: {
            tandc: "You must agree the terms and conditions.",
            part_username: {
                remote: "This username is already registered with net-it."
            },
            account_password: {
                minLength: "Your password must be at least 6 characters long."
            },
            account_password_2: {
                minLength: "Your password must be at least 6 characters long.",
                equalTo: "Please enter the same password as above."
            }
        },
        
        // the errorPlacement has to take the table layout into account 
        errorPlacement: function(error, element) { 
            if ( element.is(":radio") ) 
                error.appendTo( element.parent().next().next() ); 
            else if ( element.is(":checkbox") ) 
                error.appendTo ( element.next() ); 
            else 
                error.insertAfter(element);
        }
    });
    
    // $('#part_dob').datepicker({ 
    //                          dateFormat: 'dd/mm/yy',
    //                          maxDate: '-6y',
    //                          yearRange: "-90:+40", // this is the option you're looking for
    //                          changeMonth: true,
    //                          changeYear: true
    //                      });
});