Test Foro de elhacker.net SMF 2.1

Programación => Scripting => Mensaje iniciado por: br7 en 5 Marzo 2016, 17:34 PM

Título: [javascript] el metodo lenght me retorna "undefined" ?
Publicado por: br7 en 5 Marzo 2016, 17:34 PM
hola    ::)

aqui tengo un problema con  el metodo lenght me retorna undefined no se poque sin tanto rodeos aqui esta el codigo

inde.html

Código (html4strict) [Seleccionar]

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Validar formulario</title>
    <link rel="stylesheet" href="style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>

    <form class="formulario" action="index.php" method="post">
        <label for="nombre" > Ingrese Nombre</label>
        <input type="text" name="nombre" id="nombre"/>
        <br/ ><br/>

        <button type="button" name="button">Enviar</button>
    </form>

</body>
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="script.js" charset="utf-8"></script>
</html>



script

Código (javascript) [Seleccionar]


    $( "#nombre" ).keyup(function() {
        var value = $(this ).val();

        var n2 = value.lenght;

     //muestra undefined
     //   console.log(n2);
        alert(n2);

    });




yo se que no es un gran formulario lo que trato de hacer es una  validar que el nombre tienga un n tamano ect....

pero siempre me muestra esa palabra undefined no me explico alguna ayuda?    ;-)









Título: Re: [javascript] el metodo lenght me retorna "undefined" ?
Publicado por: Shell Root en 5 Marzo 2016, 18:10 PM
Pues porque es

Código (javascript) [Seleccionar]
value.length
Título: Re: [javascript] el metodo lenght me retorna "undefined" ?
Publicado por: br7 en 5 Marzo 2016, 18:16 PM
gracias ya veo ajajaj

yo creo que estoy ciego ajajaj :o