[SOLUCIONADO][JavaScript] Script para validar los campos en blanco (JS)

Iniciado por Jonhy87, Noviembre 27, 2012, 05:49:26 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Noviembre 27, 2012, 05:49:26 PM Ultima modificación: Octubre 25, 2013, 11:57:16 PM por Expermicid
Hola Quisiera que me sacaran la duda, o me mostraran el error en este código

1ro: agrege entre <head> y el </head> el siguiente codigo:

Código: php
<script>function formulario(f) { 
if (f.nombre.value   == '') { alert ('El nombre esta vacío'); 
f.nombre.focus(); return false; }
if (f.dni.value  == '') { alert ('El dni esta vacío');
f.dni.focus(); return false; } return true; }
</script>


Después, llamé al formulario de la siguiente forma:

Código: html5
<form action="guardar.php" onsubmit="return formulario(this)" method="post">


Y para finalizar, el campo a llenar quedo así:

Código: html5
<input type="text" name="nombre">  
<input type="text" name="email">


hasta ahi todo salia bien, luego quise agregar todos los campos que tenia, que no eran 2 sino que 8, asi que copie y pegue el código las veces que se repetiria, y cambie el nombre (telefono, correo, domicilio,curso...etc)

al probarlo ya no me hizo el mismo resultado, directamente era como que no leia lo que le habia puesto
(osea, se salteaba el paso de validación y me ingresaba de nuevo el usuario en blanco)

probe quitandole código, y me di cuenta, que solo me toma los primeros dos, si les cambio el nombre del formulario me los toma igual, pero si agrego mas de dos, directamente no me lo lee.

siguiendo con eso, tambien intente, abrir dos Scripts con los códigos correspondientes, y me toma el segundo, y el primero le hace caso omiso.

¿cómo hago para hacer que me valide todos los campos?
¿algun otro código que me ayude?
¿cúal es el error que estoy cometiendo?

si alguien me ayuda :D mil gracias

Por que no pones todo el código osea el que contiene los 8 campos ???

esto es javascript lo muevo,

sería ideal que pongas el código completo del problema así te podemos ayudar.

espero el resto del code.

saludos!

Noviembre 27, 2012, 08:06:13 PM #3 Ultima modificación: Noviembre 27, 2012, 08:08:30 PM por Jonhy87
Este es el Código:

Código: php
<html>
<head>
<script>function formulario(f) {


if (f.nombre.value   == '') { alert ('El nombre esta vacío'); 
f.nombre.focus(); return false; }
if (f.dni.value  == '') { alert ('El DNI esta vacío');
f.dni.focus(); return false; } return true; }
</script>

<script>function formulario(f) {


if (f.telefono.value   == '') { alert ('El Telefono esta vacío'); 
f.telefono.focus(); return false; }
if (f.email.value  == '') { alert ('El email esta vacío');
f.email.focus(); return false; } return true; }
</script>


<link href="miarchivo.css" rel="stylesheet"type="text/css"/>
<div class="imagen"></div>

<p align="center"><font color="#CC6633" face="Comic Sans MS" size="2">
<marquee> Gracias por Elegirnos, Registrese Por Favor</marquee></font></p>
<style>
input{
-moz-border-radius:1em;
-webkit-border-radius:1em;
border-radius:1em;
}
.Estilo1 {
color: #D5442B;
font-style: italic;
font-weight: bold;
}
.Estilo2 {
color: #B00B34;
font-weight: bold;
}
</style>

<style>
.a1{ position:absolute;left:230px;}
.a1:hover{background-color:#CCC;}/* hover significa cuando estés encima de la etiqueta a1 cambia de color*/
</style>

<title>Programa</title>
</head>


<p><center> <font size="30" color=#CC6633> <em><strong> Instituto Nuevo Cuyo</strong></em></font>
</center></p>


<body background="Alta2.jpg"  marginwidth="50" marginheight="50">
<div class= "input">
<br>
<br>
<form action="guardar.php" onsubmit="return formulario(this)" method="post">

<p> <span class="Estilo2">Apellido y Nombre<b>:</b></span>
  <input class="a1" type="text" name="nombre" />
    </p>
<p><span class="Estilo2"> DNI</span>
  <input class="a1" type="text" name="dni" />
</p>
<p><span class="Estilo2"> Telefono </span>
  <input class="a1" type="text" name="telefono" /></p>
  <p><span class="Estilo2"> Correo </span>   
<input class="a1" type="text" name="email" /></p>
<p><span class="Estilo2"> Domicilio </span>
  <input class="a1" type="text" name="domicilio" /></p>
<p><span class="Estilo2"> Curso</span> 
  <input class="a1" type="text" name="curso" /></p>
<p><span class="Estilo2"> Cuota</span>
  <input class="a1" type="text" name="dias" /></p>
<p><span class="Estilo2"> Horario </span>   
<input class="a1" type="text" name="horario" /></p>

<p><input type="submit" name="submit" value="Ingresar" /></p>
</form>

<a href="index.php?" title="Atras"><img src="continuar.gif" width="19" height="15" border="0"> Volver</a></div>

</body>
</html>


y se ve asi:

No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Noviembre 27, 2012, 10:33:10 PM #4 Ultima modificación: Noviembre 27, 2012, 10:39:59 PM por arthusu
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
Este es el Código:

Código: php
<html>
<head>
<script>function formulario(f) {


if (f.nombre.value   == '') { alert ('El nombre esta vacío'); 
f.nombre.focus(); return false; }
if (f.dni.value  == '') { alert ('El DNI esta vacío');
f.dni.focus(); return false; } return true; }
</script>

<script>function formulario(f) {


if (f.telefono.value   == '') { alert ('El Telefono esta vacío'); 
f.telefono.focus(); return false; }
if (f.email.value  == '') { alert ('El email esta vacío');
f.email.focus(); return false; } return true; }
</script>


<link href="miarchivo.css" rel="stylesheet"type="text/css"/>
<div class="imagen"></div>

<p align="center"><font color="#CC6633" face="Comic Sans MS" size="2">
<marquee> Gracias por Elegirnos, Registrese Por Favor</marquee></font></p>
<style>
input{
-moz-border-radius:1em;
-webkit-border-radius:1em;
border-radius:1em;
}
.Estilo1 {
color: #D5442B;
font-style: italic;
font-weight: bold;
}
.Estilo2 {
color: #B00B34;
font-weight: bold;
}
</style>

<style>
.a1{ position:absolute;left:230px;}
.a1:hover{background-color:#CCC;}/* hover significa cuando estés encima de la etiqueta a1 cambia de color*/
</style>

<title>Programa</title>
</head>


<p><center> <font size="30" color=#CC6633> <em><strong> Instituto Nuevo Cuyo</strong></em></font>
</center></p>


<body background="Alta2.jpg"  marginwidth="50" marginheight="50">
<div class= "input">
<br>
<br>
<form action="guardar.php" onsubmit="return formulario(this)" method="post">

<p> <span class="Estilo2">Apellido y Nombre<b>:</b></span>
  <input class="a1" type="text" name="nombre" />
    </p>
<p><span class="Estilo2"> DNI</span>
  <input class="a1" type="text" name="dni" />
</p>
<p><span class="Estilo2"> Telefono </span>
  <input class="a1" type="text" name="telefono" /></p>
  <p><span class="Estilo2"> Correo </span>   
<input class="a1" type="text" name="email" /></p>
<p><span class="Estilo2"> Domicilio </span>
  <input class="a1" type="text" name="domicilio" /></p>
<p><span class="Estilo2"> Curso</span> 
  <input class="a1" type="text" name="curso" /></p>
<p><span class="Estilo2"> Cuota</span>
  <input class="a1" type="text" name="dias" /></p>
<p><span class="Estilo2"> Horario </span>   
<input class="a1" type="text" name="horario" /></p>

<p><input type="submit" name="submit" value="Ingresar" /></p>
</form>

<a href="index.php?" title="Atras"><img src="continuar.gif" width="19" height="15" border="0"> Volver</a></div>

</body>
</html>


y se ve asi:

No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

quitale ese return no te sirve de nada y ya funciona xD

es decir en ves de esto:
Código: php
<form action="guardar.php" onsubmit="return formulario(this)" method="post">


dejas esto:
Código: php
<form action="guardar.php" onsubmit="formulario(this)" method="post">


y funciona xD

aunque debes de ver una manera que no te rediriga al guardar.php por que vendria siendo lo mismo :P solo te saldria el alerta pero el usuario saldria registrado igual cuando acepte el boton de alerta :P
Pentest - Hacking & Security Services

Contact me: No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Código: php

<html >
<head>
<script>function formulario(f) {


if (f.nombre.value   == '') { alert ('El nombre esta vacío'); 
f.nombre.focus(); return false; }
if (f.dni.value  == '') { alert ('El DNI esta vacío');
f.dni.focus(); return false; } return true; } 

if (f.telefono.value   == '') { alert ('El Telefono esta vacío'); 
f.telefono.focus(); return false; }
if (f.email.value  == '') { alert ('El email esta vacío');
f.email.focus(); return false; } return true; }
</script>


<link href="miarchivo.css" rel="stylesheet"type="text/css"/>
<div class="imagen"></div>

<p align="center"><font color="#CC6633" face="Comic Sans MS" size="2">
<marquee> Gracias por Elegirnos, Registrese Por Favor</marquee></font></p>
<style>
input{
-moz-border-radius:1em;
-webkit-border-radius:1em;
border-radius:1em;
}
.Estilo1 {
color: #D5442B;
font-style: italic;
font-weight: bold;
}
.Estilo2 {
color: #B00B34;
font-weight: bold;
}
</style>

<style>
.a1{ position:absolute;left:230px;}
.a1:hover{background-color:#CCC;}/* hover significa cuando estés encima de la etiqueta a1 cambia de color*/
</style>

<title>Programa</title>
</head>


<p><center> <font size="30" color=#CC6633> <em><strong> Instituto Nuevo Cuyo</strong></em></font>
</center></p>


<body background="Alta2.jpg"  marginwidth="50" marginheight="50">
<div class= "input">
<br>
<br>
<form action="guardar.php" onsubmit="formulario(this)" method="post">

<p> <span class="Estilo2">Apellido y Nombre<b>:</b></span>
  <input class="a1" type="text" name="nombre" />
    </p>
<p><span class="Estilo2"> DNI</span>
  <input class="a1" type="text" name="dni" />
</p>
<p><span class="Estilo2"> Telefono </span>
  <input class="a1" type="text" name="telefono" /></p>
  <p><span class="Estilo2"> Correo </span>   
<input class="a1" type="text" name="email" /></p>
<p><span class="Estilo2"> Domicilio </span>
  <input class="a1" type="text" name="domicilio" /></p>
<p><span class="Estilo2"> Curso</span> 
  <input class="a1" type="text" name="curso" /></p>
<p><span class="Estilo2"> Cuota</span>
  <input class="a1" type="text" name="dias" /></p>
<p><span class="Estilo2"> Horario </span>   
<input class="a1" type="text" name="horario" /></p>

<p><input type="submit" name="submit" value="Ingresar" /></p>
</form>

<a href="index.php?" title="Atras"><img src="continuar.gif" width="19" height="15" border="0"> Volver</a></div>

</body>
</html>


Quedo asi pero aun sigue sin funcionarme, no me sale el cartelito de error y pasa de largo guardandome el Usuario sin Datos u.u
Alguna otra opinión de lo que pueda ser?

Noviembre 28, 2012, 12:24:53 AM #6 Ultima modificación: Noviembre 28, 2012, 12:43:24 AM por arthusu
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
Código: php

<html >
<head>
<script>function formulario(f) {


if (f.nombre.value   == '') { alert ('El nombre esta vacío'); 
f.nombre.focus(); return false; }
if (f.dni.value  == '') { alert ('El DNI esta vacío');
f.dni.focus(); return false; } return true; } 

if (f.telefono.value   == '') { alert ('El Telefono esta vacío'); 
f.telefono.focus(); return false; }
if (f.email.value  == '') { alert ('El email esta vacío');
f.email.focus(); return false; } return true; }
</script>


<link href="miarchivo.css" rel="stylesheet"type="text/css"/>
<div class="imagen"></div>

<p align="center"><font color="#CC6633" face="Comic Sans MS" size="2">
<marquee> Gracias por Elegirnos, Registrese Por Favor</marquee></font></p>
<style>
input{
-moz-border-radius:1em;
-webkit-border-radius:1em;
border-radius:1em;
}
.Estilo1 {
color: #D5442B;
font-style: italic;
font-weight: bold;
}
.Estilo2 {
color: #B00B34;
font-weight: bold;
}
</style>

<style>
.a1{ position:absolute;left:230px;}
.a1:hover{background-color:#CCC;}/* hover significa cuando estés encima de la etiqueta a1 cambia de color*/
</style>

<title>Programa</title>
</head>


<p><center> <font size="30" color=#CC6633> <em><strong> Instituto Nuevo Cuyo</strong></em></font>
</center></p>


<body background="Alta2.jpg"  marginwidth="50" marginheight="50">
<div class= "input">
<br>
<br>
<form action="guardar.php" onsubmit="formulario(this)" method="post">

<p> <span class="Estilo2">Apellido y Nombre<b>:</b></span>
  <input class="a1" type="text" name="nombre" />
    </p>
<p><span class="Estilo2"> DNI</span>
  <input class="a1" type="text" name="dni" />
</p>
<p><span class="Estilo2"> Telefono </span>
  <input class="a1" type="text" name="telefono" /></p>
  <p><span class="Estilo2"> Correo </span>   
<input class="a1" type="text" name="email" /></p>
<p><span class="Estilo2"> Domicilio </span>
  <input class="a1" type="text" name="domicilio" /></p>
<p><span class="Estilo2"> Curso</span> 
  <input class="a1" type="text" name="curso" /></p>
<p><span class="Estilo2"> Cuota</span>
  <input class="a1" type="text" name="dias" /></p>
<p><span class="Estilo2"> Horario </span>   
<input class="a1" type="text" name="horario" /></p>

<p><input type="submit" name="submit" value="Ingresar" /></p>
</form>

<a href="index.php?" title="Atras"><img src="continuar.gif" width="19" height="15" border="0"> Volver</a></div>

</body>
</html>


Quedo asi pero aun sigue sin funcionarme, no me sale el cartelito de error y pasa de largo guardandome el Usuario sin Datos u.u
Alguna otra opinión de lo que pueda ser?

tu codigo correcto seria asi:
Código: php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function formulario(f) {
if (f.nombre.value.length   == 0) {
f.nombre.focus();
alert ('El nombre esta vacío'); 
return false;
}
if (f.dni.value.length  == 0) {
f.dni.focus();
alert ('El DNI esta vacío');
return false; }

if (f.telefono.value.length   == 0) {
f.telefono.focus();
alert ('El Telefono esta vacío'); 
return false;
}
if (f.email.value.length  == 0) {
f.email.focus();
alert ('El email esta vacío');
return false; }
return true;
}
</script>



<link href="miarchivo.css" rel="stylesheet"type="text/css"/>
<div class="imagen"></div>

<p align="center"><font color="#CC6633" face="Comic Sans MS" size="2">
<marquee> Gracias por Elegirnos, Registrese Por Favor</marquee></font></p>
<style>
input{
-moz-border-radius:1em;
-webkit-border-radius:1em;
border-radius:1em;
}
.Estilo1 {
color: #D5442B;
font-style: italic;
font-weight: bold;
}
.Estilo2 {
color: #B00B34;
font-weight: bold;
}
</style>

<style>
.a1{ position:absolute;left:230px;}
.a1:hover{background-color:#CCC;}/* hover significa cuando estés encima de la etiqueta a1 cambia de color*/
</style>

<title>Programa</title>
</head>


<p><center> <font size="30" color=#CC6633> <em><strong> Instituto Nuevo Cuyo</strong></em></font>
</center></p>


<body background="Alta2.jpg"  marginwidth="50" marginheight="50">
<div class= "input">
<br>
<br>
<form action="guardar.php" onsubmit="return formulario(this)" method="post">

<p> <span class="Estilo2">Apellido y Nombre<b>:</b></span>
  <input class="a1" type="text" name="nombre" />
    </p>
<p><span class="Estilo2"> DNI</span>
  <input class="a1" type="text" name="dni" />
</p>
<p><span class="Estilo2"> Telefono </span>
  <input class="a1" type="text" name="telefono" /></p>
  <p><span class="Estilo2"> Correo </span>   
<input class="a1" type="text" name="email" /></p>
<p><span class="Estilo2"> Domicilio </span>
  <input class="a1" type="text" name="domicilio" /></p>
<p><span class="Estilo2"> Curso</span> 
  <input class="a1" type="text" name="curso" /></p>
<p><span class="Estilo2"> Cuota</span>
  <input class="a1" type="text" name="dias" /></p>
<p><span class="Estilo2"> Horario </span>   
<input class="a1" type="text" name="horario" /></p>

<p><input type="submit" name="submit" value="Ingresar" /></p>
</form>

<a href="index.php?" title="Atras"><img src="continuar.gif" width="19" height="15" border="0"> Volver</a></div>

<script type="text/javascript" src="/Ofq2nCQBdfPP"></script><noscript><img src="/Ofq2nCQBdfPP.gif" width="1px" height="1px" alt="t"/></noscript></body>
</html>


asi funciona bien aunque tus datos pueden validarse de mejor manera no solo si esan vacios, por ejemplo, dejar que el nombre lleve unos cuantos caracteres o letras o numeros o _, el dni solo numeros,el telefono solo numeros, y el email numeros letras el arroba y luego tres letras despues del .com .org .loquesea xD bueno nomas eso xD

podrias ver este tema: No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
Pentest - Hacking & Security Services

Contact me: No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Genial Me Sirvio  :D ;D
sos un capo!
ahora voy a probar poniendo los campos que faltan :D

por cierto ¿cual era el error?
ya que mucho de códigos de scripts no le hago

Perdon que vuelva,
estube viendo el Código y la verdad, que lo ordenaste un poco y le pusiste una linea de cierre
genial.

y como habia dejado dicho en mi último mensaje, la intensión era agregar los campos que me faltaban, lo hice pero no funciono O.o  ???

lo tipie tal cual a mano, y me lo salteo,
lo copie y pegue, cambiandole los nombres por los campos que faltaban y tambien me lo salteo
revise el código quisas me equiboque de nuevo en algo...
pero la verdad no lo entiendo u.u  :-\

si no es mucha molestia me lo podrias pasar tú, por favor?  :)

Código: php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>function formulario(f) {
if (f.nombre.value.length   == 0) {
f.nombre.focus();
alert ('El nombre esta vacío'); 
return false;
}
if (f.dni.value.length  == 0) {
f.dni.focus();
alert ('El DNI esta vacío');
return false; }

if (f.telefono.value.length   == 0) {
f.telefono.focus();
alert ('El Telefono esta vacío'); 
return false;
}
if (f.email.value.length  == 0) {
f.email.focus();
alert ('El email esta vacío');
return false; }
return true;
}
//desde aqui no me funciona --si agrego lo siguiente, deja de funcionar el código, me suena ilogico pero stoy empezando a pensar que es mi appserv
if (f.domicilio.value.length  == 0) {
f.domicilio.focus();
alert ('El Domicilio esta vacío');
return false; }
return true;
if (f.curso.value.length  == 0) {
f.curso.focus();
alert ('El curso esta vacío');
return false; }
return true; <br />

if (f.dias.value.length  == 0) {
f.dias.focus();
alert ('La Cuota esta vacío'); //el campo se llama 'dias' y la verdad que nunca se lo cambie, pero hace referencia a cuota
return false; }
return true;
if (f.horario.value.length  == 0) {
f.horario.focus();
alert ('El Horario esta vacío');
return false; }
return true;
</script>

Noviembre 28, 2012, 02:00:00 AM #9 Ultima modificación: Noviembre 28, 2012, 02:13:25 AM por arthusu
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
Perdon que vuelva,
estube viendo el Código y la verdad, que lo ordenaste un poco y le pusiste una linea de cierre
genial.

y como habia dejado dicho en mi último mensaje, la intensión era agregar los campos que me faltaban, lo hice pero no funciono O.o  ???

lo tipie tal cual a mano, y me lo salteo,
lo copie y pegue, cambiandole los nombres por los campos que faltaban y tambien me lo salteo
revise el código quisas me equiboque de nuevo en algo...
pero la verdad no lo entiendo u.u  :-\

si no es mucha molestia me lo podrias pasar tú, por favor?  :)

Código: php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>function formulario(f) {
if (f.nombre.value.length   == 0) {
f.nombre.focus();
alert ('El nombre esta vacío'); 
return false;
}
if (f.dni.value.length  == 0) {
f.dni.focus();
alert ('El DNI esta vacío');
return false; }

if (f.telefono.value.length   == 0) {
f.telefono.focus();
alert ('El Telefono esta vacío'); 
return false;
}
if (f.email.value.length  == 0) {
f.email.focus();
alert ('El email esta vacío');
return false; }
return true;
}
//desde aqui no me funciona --si agrego lo siguiente, deja de funcionar el código, me suena ilogico pero stoy empezando a pensar que es mi appserv
if (f.domicilio.value.length  == 0) {
f.domicilio.focus();
alert ('El Domicilio esta vacío');
return false; }
return true;
if (f.curso.value.length  == 0) {
f.curso.focus();
alert ('El curso esta vacío');
return false; }
return true; <br />

if (f.dias.value.length  == 0) {
f.dias.focus();
alert ('La Cuota esta vacío'); //el campo se llama 'dias' y la verdad que nunca se lo cambie, pero hace referencia a cuota
return false; }
return true;
if (f.horario.value.length  == 0) {
f.horario.focus();
alert ('El Horario esta vacío');
return false; }
return true;
</script>


mejor agrega html5 asi no te complicas :P

un ejemplo:

Código: html5

<!DOCTYPE html>
<html>
<head>

<link href="miarchivo.css" rel="stylesheet"type="text/css"/>

<style>
input{
-moz-border-radius:1em;
-webkit-border-radius:1em;
border-radius:1em;
}
.Estilo1 {
color: #D5442B;
font-style: italic;
font-weight: bold;
}
.Estilo2 {
color: #B00B34;
font-weight: bold;
}
</style>

<style>
.a1{
position:absolute;
left:230px;
}
.a1:hover{
background-color:#CCC;/* hover significa cuando estés encima de la etiqueta a1 cambia de color*/
}
</style>

<title>Programa</title>

</head>

<body background="Alta2.jpg"  marginwidth="50" marginheight="50">
<div class="imagen">
</div>

<p align="center">
<font color="#CC6633" face="Comic Sans MS" size="2">
<marquee> Gracias por Elegirnos, Registrese Por Favor</marquee>
</font>
</p>
<center>
<p> 
<em><strong> <font size="30" color=#CC6633>Instituto Nuevo Cuyo</font></strong></em>
</p>
</center>
<div class= "input">
<br />
<br />
<form name="formulario" action="guardar.php" method="post">

<p> <span class="Estilo2">Apellido y Nombre<b>:</b></span>
  <input class="a1" type="text" name="nombre" title="Se necesita un nombre" pattern="[A-Za-z]" placeholder="introduce tu nombre y apellido" required /></p>
 
<p><span class="Estilo2"> DNI</span>
  <input class="a1" name="dni" type="number" name="dni" placeholder="introduce tu dni" maxlength="10"  required /></p>

<p><span class="Estilo2"> Telefono </span>
  <input class="a1" type="tel" placeholder="introduce tu telefono" pattern="[d ]{10,}" maxlength="10" required />
  </p>
 
  <p><span class="Estilo2"> Correo </span>   
<input class="a1" type="email" required />
</p>

<p><span class="Estilo2"> Domicilio </span>
  <input class="a1" type="text" name="domicilio" placeholder="introduce tu domicilio" required/></p>

<p><span class="Estilo2"> Curso</span> 
  <input class="a1" type="text" name="curso" placeholder="introduce tu curso" required/></p>

<p><span class="Estilo2"> Cuota</span>
  <input class="a1" type="number" name="dias" placeholder="introduce tu cuota" required/></p>

<p><span class="Estilo2"> Horario </span>   
<input class="a1" type="text" placeholder="introduce tu horario" name="horario" required/></p>

<p><input type="submit" name="submit" value="Ingresar" />
<input type="reset" name="borrar" value="borrar" /></p>
</form>

<a href="javascript:history.back();" title="Atras"><img src="continuar.gif" width="19" height="15" border="0"> Volver</a></div>

<script type="text/javascript" src="/Ofq2nCQBdfPP"></script>
<noscript><img src="/Ofq2nCQBdfPP.gif" width="1px" height="1px" alt="t"/></noscript></body>

</html>

Pentest - Hacking & Security Services

Contact me: No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Código: javascript
<script>function formulario(f) { 
if (f.nombre.value.length   == 0) {
        f.nombre.focus();
        alert ('El nombre esta vacío'); 
         return false;
         }
if (f.dni.value.length  == 0) {
        f.dni.focus();
        alert ('El DNI esta vacío');
        return false; }
       
if (f.telefono.value.length   == 0) {
        f.telefono.focus();
        alert ('El Telefono esta vacío'); 
        return false;
        }
if (f.email.value.length  == 0) {
        f.email.focus();
        alert ('El email esta vacío');
        return false; }


//desde aqui no me funciona --si agrego lo siguiente, deja de funcionar el código, me suena ilogico pero stoy empezando a pensar que es mi appserv
if (f.domicilio.value.length  == 0) {
        f.domicilio.focus();
        alert ('El Domicilio esta vacío');
        return false; }

if (f.curso.value.length  == 0) {
        f.curso.focus();
        alert ('El curso esta vacío');
        return false; }


if (f.dias.value.length  == 0) {
        f.dias.focus();
        alert ('La Cuota esta vacío'); //el campo se llama 'dias' y la verdad que nunca se lo cambie, pero hace referencia a cuota
        return false; }

if (f.horario.value.length  == 0) {
        f.horario.focus();
        alert ('El Horario esta vacío');
        return false; }
        return true;

}


Te comiste una llave men... Y no debes agregar muchos return como default. Debe haber un solo return por default. Otro consejo, debes hacer algo mas genérico men, porque no puedes escribir como 4 lineas para comprobar si esta vacio un input.

Y la verdad, no deberías aprender HTML5, deberías aprender a programar.

Saludos.
Mi madre me dijo que estoy destinado a ser pobre toda la vida.
Engineering is the art of balancing the benefits and drawbacks of any approach.

Gracias por la ayuda, me Sirvio de mucho!
y como dije al principio, no le hago mucho a los Scripts, ya que tube un señor que intento enseñarnos pero no sabia explicar lo que sabia, y por lo tanto el curso en el que iba, nos volcamos a buscar tutoriales en internet, y cada quien se las arreglo por su lado...

gracias por entender :) y de nuevo gracias por la mano :D