function rutDarFormato() {
    $('#txt_rut').val(darformatoRut($('#txt_rut').val()));
}

$(document).ready(function() {
    $('#txt_rut').keyup(function () {
		rutDarFormato();
	});
    
    $("#frm_funcionario").validate({
        rules: {
            txt_apellidoPaterno: {
                required: true
            },
            txt_apellidoMaterno: {
                required: true
            },
            txt_nombre: {
                required: true
            },
            txt_rut: {
				required    : true,
                validar_rut : true
			},
            txt_telefonoCelular: {
				required        : true,
                digits          : true,
                validar_numeros : true,
                minlength       : 9,
                maxlength       : 9
			},
			txt_email: {
				required   : true,
                email      : true
			},
			txt_direccion: {
				required: true
			},
			cmb_rol: {
				required: true
			}
        },
        submitHandler: function(form) {

            guardarFuncionario();

        },
        highlight: function(element) {
            $(element).closest('div').addClass('has-error');
        },
        unhighlight: function(element) {
            $(element).closest('div').removeClass('has-error');
        },
        errorElement: 'span',
        errorClass: 'help-block'
    });

});


