PHP - Ayuda formularios!

 
Vista:

Ayuda formularios!

Publicado por Emiliano (1 intervención) el 28/06/2009 21:23:35
tengo el siguiente problema.. necesito enviar un formulario de contacto y validar que los campos sean correctos.. hasta ahí mi solución funciona, pero quiero que si algún dato es erróneo no me borre todos los campos para comenzar de 0 a completarlo sino que vuelva con los datos que ya había ingresado anteriormente...
les voy a agradecer enormemente la ayuda!!!
les pego el código:

Contacto.php:

<form id="contacto" height = "300" width="600" align="center">
<br>
<p align="center"> <h4 align="center">Por favor complete los campos: </h4></p>
<font color="858585"><b>
<div id="celdas"><div> Apellido y Nombre:
<br><br>
E-mail:
<br><br>
Asunto:
<br><br>
Nos conocio por:
</b><p><p>
</div>

<div> <input type="text" name="nombre" id="nombre" size="25">
<br><br>
<input type="text" name="email" id="email" size="25">
<br><br>
<input type="text" name="asunto" id="asunto" size="25">
<br><br>
   Internet<input type="checkbox" name="web" style="CURSOR: url('hand.cur'), auto">

Periódico<input type="checkbox" name="periodico" style="CURSOR: url('hand.cur'), auto">

Otros<input type="checkbox" name="otros" style="CURSOR: url('hand.cur'), auto">

<br><br>
</div>

<div> <img src="./imagenes/manos.png" border="0" >
</div>
</div>
<br class="clearfloat">
<div> <div id="celdas2"><div><b>Mensaje:</b>
</div>
<div> <textarea cols= '35' rows= '7' name="mensaje" id="mensaje"></textarea>
<p><p>
</div>

</div>
</font>
<br class="clearfloat">
<div align="right"> <input type="reset" name="limpiar" value="Limpiar" style="CURSOR: url('hand.cur'), auto">
<input type="Submit" name="enviar" value="Enviar" onClick="comprobar();" style="CURSOR: url('hand.cur'), auto">
      
</div>

</form>

y la función comprobar completa sería:

Código:

function validaremail(txt){
var b = /^[^@s]+@[^@.s]+(.[^@.s]+)+$/

if (!b.test(txt)) {
alert('Email no vxe1lido.');
}
return b.test(txt)
}


function comprobar() {


if ((document.getElementById('nombre').value == '') || (document.getElementById('email').value == '')

|| (document.getElementById('asunto').value == '') || (document.getElementById('mensaje').value == ''))

{
alert('Debe Completar todos los datos requeridos.');
}
else

{
validaremail(document.getElementById('email').value)
}
}

espero su ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ayuda formularios!

Publicado por KAMALEON (9 intervenciones) el 29/06/2009 23:05:50
HOLA , LO Q ESTA SNESESITANDO ES Q SE VALIDEN LOS CAMPOOS DESDE EL LADO DEL CLIENTE, ENTONCES UAN SUGERENCIA SERIA Q COLOKES EL BOTON PERO TIPO BUTTON , EN VES DE SUBMIT, ALGO ASI:

<input type="button" name="enviar" value="Enviar" onClick="comprobar();" style="CURSOR: url('hand.cur'), auto">

PARA QUE NO TE ENVIE LOS DATOS DEL FORMULARIOS POR DEFECTO, YA Q S COLOCAS TIPO SUBMIT SE EJECUTARA EL ENVIO DE DATOS DE TODA SMANERAS.

Y TU FUNCOINE KEDAROIA COMO :

function validaremail(txt){
var b = /^[^@s]+@[^@.s]+(.[^@.s]+)+$/

if (!b.test(txt)) {
alert('Email no vxe1lido.');
return 0;
}

document.NOMBRE:FORMULARIO.submit(); //RECIEN ENVIA LOS DATOS
}

function comprobar() {

if ((document.getElementById('nombre').value == '') || (document.getElementById('email').value == '')

|| (document.getElementById('asunto').value == '') || (document.getElementById('mensaje').value == ''))

{
alert('Debe Completar todos los datos requeridos.');
return 0;
}
else

{
validaremail(document.getElementById('email').value)
}
}


PUEDES BUSCAR MS INFO SOBRE: VALIDAR DATOS DEL LADO DEL CLIENTE.

ACA HAY UAN PAGINA:
http://www.desarrolloweb.com/articulos/1767.php


ESPERO TE SIRVA . SALUDOS DESDE CHIMBOTE-PERU
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ayuda formularios!

Publicado por Rafael (1 intervención) el 19/08/2009 16:12:59
Hola buen dia a todos pido ayuda por este medio en crear un formulario de contacto lo he intentado y el formulario me llega en blanco. Debe ser un formulario con campo nombre, mensaje, telefono, esos tres valores deben ir en lugar de 3333 de la url del form action que pongo aca. Muchas gracias de antemano.
http://smsinternet.movilnet.com.ve/smsinternet/validarCliente.jsp?codigo=158&numero=8209294&mensaje=3333&servicio=cantvnet
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar