LO LOGRE
no es el mismo codigo pero funciona, si alguien quiere aportar alguna mejora sera bienvenida.
Código HTML:
function validar(f) {
var errorMsg = "";
if (f.nombre.value== "") {
errorMsg += "\n\tNombre \t- Debe cargar el Nombre, es un dato obligatorio";
}
if (f.apellido.value== "") {
errorMsg += "\n\tApellido \t- Debe cargar el Apellido, es un dato obligatorio";
}
if (f.email.value== "") {
errorMsg += "\n\tE-mail \t- Debe cargar el Email, es un dato obligatorio";
}
if (f.email2.value== "") {
errorMsg += "\n\tE-mail2 \t- Debe cargar el segundo Email, es un dato obligatorio";
}
if(f.email.value!="" && f.email2.value!=""){
if (f.email.value != f.email2.value) {
errorMsg += "\n\tConfirmación de E-mail \t- Los campos de email tienen que ser iguales";
}
}
if (errorMsg != ""){
msg = "______________________________________________________________\n\n";
msg += "ERROR!.\n";
msg += "Por Favor revise los datos ingresados.\n";
msg += "______________________________________________________________\n\n";
errorMsg += alert(msg + errorMsg + "\n\n");
return false;
}
return true;
}