Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/07/2009, 12:49
Avatar de ceaped
ceaped
 
Fecha de Ingreso: febrero-2004
Mensajes: 2.185
Antigüedad: 21 años, 2 meses
Puntos: 9
Este código JavaScript no me es válido por W3c

Buenas tardes para todos.

Estoy utilizando este código que encontré en el Foro:

Cita:
<script language="JavaScript">
function Validar(form){
var pos1, pos2, bOk = true;
var sDir = document.miFormu.email.value;
var coment = document.miFormu.comentario.value;
if (sDir == ""){
alert("Por favor ingrese su direccin de correo");
document.miFormu.email.focus();
return false;
}
if (coment == ""){
alert("Por favor ingrese su Receta");
document.miFormu.comentario.focus();
return false;
}
pos1 = sDir.indexOf('@', 0);
pos2 = sDir.indexOf('.', 0);
bOk = bOk && (pos1 > 0);
bOk = bOk && (pos2 != -1);
bOk = bOk && (pos1 < pos2 - 1);
bOk = bOk && (pos2 < sDir.length - 1);
if (!bOk){
alert("Direcci n de correo invlida. Verifique la @ o el ' . '");
document.miFormu.email.focus();
return false;
}
}
</script>

<script language="JavaScript" type="text/javascript">
function irA(url){
location.href = url;
}
</script>
Para este formulario

Cita:
<form name="miFormu" action="agregar.php" method="post" onsubmit="return Validar(this);">
<h6>Haz tu aporte y agrega tu receta preferida:</h6>
<br />
<input type="hidden" name="id" size="40" value="<? echo $id; ?>" />
<h6>Nombre o Nik</h6>
<input type="text" name="nick" size="40" />
<h6>email (requerido). <em>No ser&aacute; revelado</em> </h6>
<input type="text" name="email" size="40" />
<h6>Escriba la Receta</h6>
<textarea name="comentario" cols="30" rows="5"></textarea>
<br />
<input type="submit" value="Enviar" onClick="JavaScript:validar_email();"/>
<input type="reset" value="Borrar" />
</form>
Funciona OK. Pero la W3c NO me lo valida. Tiene algún error. Cual es.
O si hay algún otro código que sí sea válido.

Gracias por su ayuda
__________________
Diseñador Gráfico publicitario