$().ready(function () {

    // validate signup form on keyup and submit
    $("#contacto_form").validate({
        rules: {
            nombre: "required",
            apellido: "required",
            email: {
                required: true,
                email: true
            },
            comentario: "required"
        },
        messages: {
            nombre: {
                required: '*'
            },
            apellido: {
                required: '*'
            },
            email: {
                required: '*',
                email: '*'
            },
            comentario: {
                required: '*'
            }
        },
        invalidHandler: function (form, validator) {
            var errors = validator.numberOfInvalids();
            if (errors) {
                $('#warning').html('<span>*</span> <b>CAMPOS OBLIGATORIOS</b>');
            }
            else {
                $('#warning').html('');
            }
        },
        submitHandler: function (form) {
            //alert('valid form');
            $.ajax({
                type: "POST",
                url: $(form).attr('action'),
                data: $(form).serialize(),
                success: function (data) {
                    $('#contacto_form').trigger("reset");
                    $('#warning').html('CONSULTA RECIBIDA. GRACIAS.');
                }
            });
            return false;
        }

    });

    $("#contacto_form2").validate({
        rules: {
            nombre: "required",
            apellido: "required",
            email: {
                required: true,
                email: true
            },
            comentario: "required"
        },
        messages: {
            nombre: {
                required: '*'
            },
            apellido: {
                required: '*'
            },
            email: {
                required: '*',
                email: '*'
            },
            comentario: {
                required: '*'
            }
        },
        invalidHandler: function (form, validator) {
            var errors = validator.numberOfInvalids();
            if (errors) {
                $('#warning2').html('<span>*</span> <b>CAMPOS OBLIGATORIOS</b>');
            }
            else {
                $('#warning2').html('');
            }
        },
        submitHandler: function (form) {
            //alert('valid form');
            $.ajax({
                type: "POST",
                url: $(form).attr('action'),
                data: $(form).serialize(),
                success: function (data) {
                    $('#contacto_form2').trigger("reset");
                    $('#warning2').html('CONSULTA RECIBIDA. GRACIAS.');
                }
            });
            return false;
        }

    });
});	