Foros del Web » Programando para Internet » Javascript »

necesito ayuda con este script

Estas en el tema de necesito ayuda con este script en el foro de Javascript en Foros del Web. Haber si me podriais ayudar, necesito añadir a mi script un codigo para impedir que el siguiente formulario pueda ser reenviado, preferiblemente que salga una ...
  #1 (permalink)  
Antiguo 24/06/2006, 12:08
 
Fecha de Ingreso: abril-2006
Mensajes: 34
Antigüedad: 18 años
Puntos: 0
necesito ayuda con este script

Haber si me podriais ayudar, necesito añadir a mi script un codigo para impedir que el siguiente formulario pueda ser reenviado, preferiblemente que salga una alerta diciendo que ya ha sido enviado al darle al boton enviar y no permita el reenvio.
Código:
<html>
<head>
<title>Formulario</title>
<script LANGUAGE="JavaScript">

function Validar(form)
{
  if (form.Nombre.value == "")
  { alert("Por favor escriba su nombre"); form.Nombre.focus(); return; }

  if (form.Apellidos.value == "")
  { alert("Por favor escriba sus apellidos"); form.Apellidos.focus(); return; }

  if (form.Pais.value == "")
  { alert("Por favor indique su pais"); form.Pais.focus(); return; }

  if (form.Provincia.value == "")
  { alert("Por favor indique su provincia"); form.Provincia.focus(); return; }

  if (form.Ciudad.value == "")
  { alert("Por favor indique su ciudad"); form.Ciudad.focus(); return; }

  if (form.Domicilio.value == "")
  { alert("Por favor indique su domicilio"); form.Domicilio.focus(); return; }

  if (form.CodPost.value == "")
  { alert("Por favor escriba su código de su codigo postal"); form.CodPost.focus(); return; }
 
  if (form.Email.value == "")
  { alert("Por favor escriba su dirección de e-mail"); form.Email.focus(); return; }

  if (form.Email.value.indexOf('@', 0) == -1 ||
      form.Email.value.indexOf('.', 0) == -1)
  { alert("Dirección de e-mail inválida"); form.Email.focus(); return; }

  if (form.Telefono.value == "")
  { alert("Por favor escriba su número de teléfono"); form.Telefono.focus(); return; }

  if (!form.checkbox.checked)
  { alert("Debe aceptar los Terminos y Condiciones");form.checkbox.checked; return; }

  form.submit();
}

</script>
</head>

<body text="#FFFF00" bgcolor="#000000">
<form method="post" action="enviarform.php">
<div align="center"><center>

<table border="0" cellpadding="0" cellspacing="0" width="100%" height="147">
  <tr>
    <td width="15%" height="21">&nbsp; Nombre:</td>
    <td width="21%" height="21"><input type="text" name="Nombre" size="15"></td>
    <td width="15%" height="21">&nbsp; Apellidos:</td>
    <td width="21%" height="21"><input type="text" name="Apellidos" size="15"></td>
  </tr>
  <tr>
    <td width="15%" height="23">&nbsp; Pais: </td>
    <td width="21%" height="23"><input type="text" name="Pais" size="15"></td>
    <td width="15%" height="23">&nbsp; Provincia:</td>
    <td width="21%" height="23"><input type="text" name="Provincia" size="15"></td>
  </tr>
  <tr>
    <td width="15%" height="23">&nbsp; Ciudad:</td>
    <td width="21%" height="23"><input type="text" name="Ciudad" size="15"></td>
    <td width="15%" height="23">&nbsp; Domicilio:</td>
    <td width="21%" height="23"><input type="text" name="Domicilio" size="15"></td>
  </tr>
  <tr>
    <td width="15%" height="21">&nbsp; Codigo Postal:</td>
    <td width="21%" height="21"><input type="text" name="CodPost" size="15"></td>
    <td width="15%" height="21">&nbsp; E-mail:</td>
    <td width="21%" height="21"><input type="text" name="Email" size="15"></td>
  </tr>
  <tr>
    <td width="15%" height="23">&nbsp; Telefono:</td>
    <td width="21%" height="23"><input type="text" name="Telefono" size="15"></td>
    <td width="15%" height="23">&nbsp; Fecha de Nac.:</td>
    <td width="21%" height="23"><input type="text" name="Dia" size="2"><select name="Mes"
    size="1">
      <option value="Enero">Enero</option>
      <option value="Febrero">Febrero</option>
      <option value="Marzo">Marzo</option>
      <option value="Abril">Abril</option>
      <option value="Mayo">Mayo</option>
      <option value="Junio">Junio</option>
      <option value="Julio">Julio</option>
      <option value="Agosto">Agosto</option>
      <option value="Septiembre">Septiembre</option>
      <option value="Octubre">Octubre</option>
      <option value="Noviembre">Noviembre</option>
      <option value="Diciembre">Diciembre</option>
    </select><input type="text" name="año" size="4"></td>
  </tr>
</table>
</center></div><div align="center"><center>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td width="100%"><div align="center"><center><table border="0" cellpadding="0"
    cellspacing="0" width="100%">
      <tr>
        <td width="100%"><p align="center"><big><big>Importante:</big></big></td>
      </tr>
      <tr>
        <td width="100%"><p align="center"><textarea rows="4" name="texto" cols="40"><textarea></td>
      </tr>
      <tr>
        <td width="100%"><p align="center"><input TYPE="checkbox" name="checkbox"><font
        color="#FFFF00"> Acepto los Terminos y Condiciones.</font></td>
      </tr>
      <tr>
        <td width="100%"><p align="center"><font face="Arial" color="#000000"><small><input
        type="submit" value="Enviar" onClick="Validar(this.form)"><input TYPE="reset"></small></font></td>
      </tr>
    </table>
    </center></div></td>
  </tr>
</table>
</center></div>
</form>
</body>
</html>
  #2 (permalink)  
Antiguo 24/06/2006, 13:21
Avatar de kerverus  
Fecha de Ingreso: junio-2006
Ubicación: Okinawa
Mensajes: 9
Antigüedad: 17 años, 10 meses
Puntos: 0
algo asi como que se creara un cookie para saver que ya se hiso el envio?

Cita:
dwdpa.com/modules.php?name=java
Cita:
electros.tk
Date una vueltita por esos site.
  #3 (permalink)  
Antiguo 25/06/2006, 04:07
 
Fecha de Ingreso: abril-2006
Mensajes: 34
Antigüedad: 18 años
Puntos: 0
basicamente q no te permitiera reenviarlo y luego se abriera una ventana de alerta de windows diciendo por ejemplo: ya ha sido enviado este formulario
  #4 (permalink)  
Antiguo 26/06/2006, 02:46
 
Fecha de Ingreso: enero-2005
Ubicación: Pontevedra
Mensajes: 45
Antigüedad: 19 años, 3 meses
Puntos: 1
Mira prueba con esto, una vez haces click en el boton lo deshabilitas, compruebas los campos y despues envias el formulario:
Código:
<html>
<head>
<title>Formulario</title>
<script LANGUAGE="JavaScript">

function Validar(form)
{
form.Enviar.disabled=true;

  if (form.Nombre.value ==""){
	 alert("Por favor escriba su nombre"); 
	 form.Enviar.disabled=false;
	 form.Nombre.focus();
	return;
 }
 else{
 alert("Formulario enviado");
  form.action="enviarform.php"
  form.submit();


}
}

</script>
</head>

<body text="#FFFF00" bgcolor="#000000">
<form method="post">
<div align="center"><center>

<table border="0" cellpadding="0" cellspacing="0" width="100%" height="147">
  <tr>
    <td width="15%" height="21">&nbsp; Nombre:</td>
    <td width="21%" height="21"><input type="text" name="Nombre" size="15"></td>
 
  </tr>
      <tr>
        <td width="100%"><p align="center"><font face="Arial" color="#000000"><small><input
        type="submit" name="Enviar"  value="Enviar" onClick="Validar(this.form)"><input TYPE="reset"></small></font></td>
      </tr>
   
</table>
</center></div>
</form>
</body>
</html>

A ver si te sirve asi :P
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:02.