martes, 21 de marzo de 2017

Formulario que nos pide tre nombres y comprueba que no haya campos vacios antes de enviar el formulario

<!-- ). Formularios, validación longitud, email, etc. Expresiones regulares. -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script>
    function Valida(miForm) {
        /* Validación de campos NO VACÍOS */
        if ((miForm.Jugador1.value.length == 0) ||
        (miForm.Jugador2.value.length ==0) ||
        (miForm.Jugador3.value.length ==0)){
            alert('falta información en los campos');
            return false;
        }
        return true;
        }
       
</script>
</head>

<body>
<form name="miForm" method="get" onsubmit="return Valida(this)" action="mailto:mi@mail.com" >
    <p>
    Jugador1 <input type="text" name="Jugador1"><br>
    Jugador2 <input type="text" name="Jugador2"><br>
    Jugador3 <input type="text" name="Jugador3"><br>
    <input type="submit" value="Enviar" name="enviar"/>
    </p>
</form>
</body>
</html>

No hay comentarios:

Publicar un comentario