Ver Mensaje Individual
  #5 (permalink)  
Antiguo 22/08/2009, 10:23
diego1311
 
Fecha de Ingreso: diciembre-2008
Ubicación: Lima - Perú
Mensajes: 187
Antigüedad: 15 años, 5 meses
Puntos: 3
Respuesta: validar formulario error

Hola , raul romero tiuene razon.. aca te dejo otro codigo para que veas qeue tambien te alerta de que olvidas el @

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
script language="JavaScript"
var 
bError false
function 
validar_email() 

    if (
document.form1.mail.value.indexOf('@')==-1
    {
        
alert ("Debes colocar una \"Dirección de Email\" válida"); 
        
bError=true;
        
document.form1.mail.focus()         
    }
    else
        
bError=false;


function 
noVacio() 

    var 
i
    
n=(document.forms[0].elements.length-1);
    
    for (
i=0;i<n;i++)
    { 
        if (!
document.forms[0].elements[i].value)
        { 
            
alert("Campo inválido"); 
            
document.forms[0].elements[i].focus(); 
            
bError=true;
            break; 
        } 
        else
            
bError=false;
    } 
    
    if ((
document.form1.mail.value)&&(!bError))
        
validar_email();
     
    if (!
bError
    {
        
alert("Ok, ahora si puedes submitar este formulario");
        
document.form1.submit();
    }
}

</script> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>::Formulario de contacto::</title>
</head>
<body>
<form name="form1" id="fom1" action="mail.php" method="post">
<table width="218">
<tr>
    <td>Nombre</td>
    <td><input name = "nombre" type = "text" id="nombre" /></td>
</tr>
<tr>
    <td>Tu Email</td>
    <td><label>
        <input type="text" name="mail" id="mail" />
        </label></td>
</tr>
<tr>
    <td>Area</td>
    <td><select name="areas" id"areas">
    <option>-seleccione destino-</option>
    <option value ="1" >Consolidacion</option>
    <option value ="2">Grupos de Paz</option>
    <option value ="3">Escuelas</option>    
    <option value ="4">Evangelismo</option>
    </select></td>
</tr>
<tr>
    <td>Mensaje</td>
    <td><textarea name="mensaje" cols="17" rows="4" id="mensaje"></textarea></td>
    </tr>
<tr>
    <td>&nbsp;</td>
    <td><input type="button" name="enviar" id="enviar" value="Enviar mensaje" onclick="noVacio()"/></td>
</tr>
</table>
</FORM>
</body>
</html>