Uncaught Referenceerror: $ is not defined

Asked

Viewed 8,435 times

2

Where did I go wrong? form test

<script type="text/javascript" >
    $(document).ready(function(){
        $('#meuForm').validate({
            rules:{
                nome:{
                required: true
                },
                email:{
                    required: true
                },
                telefonefixo:{
                    required: true
                },
                celular:{
                    required: true
                }
            },
            messages:{
            nome:{
                required: "O campo é obrigatorio."
                },
                email:{
                    required: "O campo é obrigatorio."
                },
                telefonefixo:{
                    required: "O campo é obrigatorio."
                },
                celular:{
                    required: "O campo é obrigatorio."
                }
            }

        });
    });
</script>

</head>
<body>
<form name="meuForm" action="" method="POST">
NOME:<br>
<input type="text" name="nome" /><br>
Email:<br>
<input type="text" name="email" /><br>
telefone fixo:<br>
<input type="text" name="telefonefixo" /><br>
Celular:<br>
<input type="text" name="celular" /><br>
<input type="submit" name="Cadastrar" />
</form>

</body>
</html>

yes ultilized in header

 <script type="text/javascript" href="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js" > </script>
<script type="text/javascript" href="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" > </script>
  • 1

    You included the jQuery library at the head of the page?

  • sim ultilizei <script type="text/javascript" href="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js" > </script> <script type="text/javascript" href="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" > </script script script>

  • The @Luishenrique answer is correct. And also be sure to put the references before the question script

  • Don’t forget to set an id to your form, to use the validate, because #meuForm would refer to an id and not its name;

1 answer

8


Your input syntax for scripts is wrong.

There is no attribute href for the script tag, but yes src.

Replace the inclusions with:

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>

Any questions, see the w3s manual: http://www.w3schools.com/tags/tag_script.asp

Browser other questions tagged

You are not signed in. Login or sign up in order to post.