Ver Mensaje Individual
  #5 (permalink)  
Antiguo 23/05/2009, 04:45
Avatar de jonak
jonak
 
Fecha de Ingreso: mayo-2009
Mensajes: 34
Antigüedad: 15 años
Puntos: 0
Respuesta: comprobar campos de texto

Esto es todo lo que necesitas. No dejes nunca de validar luego el formulario con php.

Código HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Validar Formulario</title>
<script type="text/javascript">

function Validar(formulario){
	if(formulario.nombre.value=="")
		alert('Complete el campo \'Nombre\'.')
	else if(formulario.apellidos.value=="")
		alert('Complete el campo \'Apellidos\'.')
	else
		formulario.submit();
}

</script>
</head>
<body>
<form id="formulario_A" method="post" action="">
	Nombre: <input type="text" name="nombre" id="nombre" /><br />
    Apellidos <input type="text" name="apellidos" id="apellidos" /><br />
    <input type="button" onclick="Validar(this.form)" value="Validar" />
</form>
</body>
</html> 

Última edición por jonak; 23/05/2009 a las 08:30