$(document).ready(forms);


function forms()
{
    $('form.formulario_general').submit(function () {
        var valido = true;
        $(this).find('input').each(function () {
            if ($(this).attr('type') != 'file')
            {
                var requerido = false;
                var name = $(this).attr('name');
                if (name.substring(0,4) == 'req_')
                    requerido = true;
                if ($(this).attr('type') != 'checkbox' && $.trim($(this).val()) == '' && requerido)
                {
                    valido = false;
                    $(this).css('border','red solid 1px');
                }
                else if ($(this).attr('type') == 'checkbox' && requerido && !$(this).is(':checked'))
                {
                    valido = false;
                    $(this).next().css('color','red');
                }
                else
                {
                    $(this).css('border','');
                    $(this).css('color','');
                }
            }
        });
        if (!valido) {
		alert("Faltan campos obligatorios.\nMissing required fields.");
		return false;
	}
        else return true;
    });
}