function $() { if (arguments.length == 1) return get$(arguments[0]); var elements = []; $c(arguments).each(function(el){ elements.push(get$(el)); }); return elements; function get$(el){ if (typeof el == 'string') el = document.getElementById(el); return el; } } function validarDatosContacto() { if ($('contacto_usuario').value.length<1) { alert('Es necesario que ingrese su Usuario.'); $('contacto_usuario').focus(); return false; } else { return true; }; }; $('form_contacto').onsubmit = validarDatosContacto;