jQuery Validate - Password confirmation equalTo doesnt work

im trying to do a form with password confirmation to compare the password repetition and give a error if the passwords are different using jquery.validate, my code is this:

<script type="text/javascript">
  $( "#formulario" ).validate({
       rules: {
                nombre: { required: true, number: false, minlength: 1 },
                email: { required: true, email: true },
                cp: { required: true, number: true, minlength: 5, maxlength: 5 },
                password: { required: true, minlength: 6 },
                password2: { required: true, minlength: 6, equalTo: "#password" }
              },
       messages: {
                nombre: "Introduce un nombre correcto",
                email: "Introduce un email correcto",
                cp: "Introduce un codigo postal correcto",
                password: "la contraseña debe tener un minimo de 6 caracteres",
                password2: "las contraseñas tienen que ser iguales"
                }
       });
    });
</script>

<form id="formulario" method="post">
    <p>
      <label for="cp" class="hide">Nombre</label>
      <input type="text" name="nombre" value="" id="nombre" class="required" />
    </p>
    <p>
      <label for="email" class="hide">Email</label>
      <input type="text" name="email" value="" id="email" class="required" />
    </p>
    <p>
      <label for="cp" class="hide">Codigo postal</label>
      <input type="text" name="cp" value="" id="cp" class="required" />
    </p>
    <p>
      <label for="password" class="hide">Contraseña</label>
      <input type="password" name="password" id="password" class="required"/>
    </p>
    <p>
      <label for="password2" class="hide">rrrr Contraseña</label>
      <input type="password" name="password2" value="" id="password2" class="required" />
    </p>
    <p>
      <button type="submit" id="submit" name="submit">Enviar</button>
    </p>
</form>

What im doing wrong?

Thanks!

Answers


Question is solved, i changed this:

$( "#formulario" ).validate({

to this:

 jQuery(function ($) {
    $("#formulario").validate({

Now it's working, thanks ppl


Need Your Help

Rebuilding the Screwturn wiki search index

search indexing wiki rebuild screwturn

My wiki started returning incomplete search results.

Get an error when trying to set the build version with the AssemblyInfo Task

visual-studio-2008 msbuild msbuild-task assemblyinfo

I've added the AssemblyInfo Task reference to my C# project file (VS2008 .NET 3.5), but when I build I get the following error