Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/05/2008, 15:22
piropeator
 
Fecha de Ingreso: mayo-2008
Mensajes: 10
Antigüedad: 16 años
Puntos: 0
Validar Formulario con Javascript y pasarlo a php

Tengo un formulario que es validado y si no se ingresa nada al dar click en el botón, devuelve el foco al formulario. Y cuando se ingresa un nombre recién pasa el nombre al otro archivo para que lo muestre, este último está en PHP.

Pero cuando le doy click en el botón se pasa y no muestra nada, lo cual no debería hacer. Qué está fallando???

******** form_ingreso.html

<html>
<title>Datos de Usuario</title>
<script>
function valida_envia(){
//valido el nombre
if (document.fvalida.nombre.value.length==0){
alert("Tiene que escribir su nombre")
document.fvalida.nombre.focus()
return 0;
} else {
//el formulario se envia
alert("Dato correcto");
document.fvalida.submit();
}
}
</script>
</head>

<body>
<form name="fvalida" onsubmit="return valida_envia();" method="POST" action="form_muestra.php">
<table width="383" border="0" bgcolor="#FFFFFF">
<tr>
<th scope="row"><div align="right">Nombre :</div></th>
<td><input type="text" name="nombre"/></td>
</tr>
<tr>
<th colspan="2" scope="row">
<input type="submit" value="Aceptar"/> </th>
</tr>
</table>
</form>
</body>
</html>

***** form_muestra.php
<head>
<title>EJEMPLO</title>
</head>

<body>
El nombre se fue : <?php echo $_POST['nombre'] ?>
</body>
</html>