Problems with validation

Problems with validation

Hello,

I'm having some problems with validation. I have a specific js file for my validation funcions.
But each time I change the name of the form to validate ( and update the form in the validation function of course ) it just stop working.

For example:
The Function:
  1. $(function () {
  2.     // validate signup form on keyup and submit
  3.     var validator = $("#signupform").validate({
  4.         rules: {
  5.             firstname: "required",
  6.             lastname: "required",
  7.             username: {
  8.                 required: true,
  9.                 minlength: 2,
  10.                 remote: "users.php"
  11.             },
  12.             password: {
  13.                 required: true,
  14.                 minlength: 5
  15.             },
  16.             password_confirm: {
  17.                 required: true,
  18.                 minlength: 5,
  19.                 equalTo: "#password"
  20.             },
  21.             email: {
  22.                 required: true,
  23.                 email: true,
  24.                 remote: "emails.php"
  25.             },
  26.             dateformat: "required",
  27.             terms: "required"
  28.         },
  29.         messages: {
  30.             firstname: "Enter your firstname",
  31.             lastname: "Enter your lastname",
  32.             username: {
  33.                 required: "Enter a username",
  34.                 minlength: jQuery.format("Enter at least {0} characters"),
  35.                 remote: jQuery.format("{0} is already in use")
  36.             },
  37.             password: {
  38.                 required: "Provide a password",
  39.                 rangelength: jQuery.format("Enter at least {0} characters")
  40.             },
  41.             password_confirm: {
  42.                 required: "Repeat your password",
  43.                 minlength: jQuery.format("Enter at least {0} characters"),
  44.                 equalTo: "Enter the same password as above"
  45.             },
  46.             email: {
  47.                 required: "Please enter a valid email address",
  48.                 minlength: "Please enter a valid email address",
  49.                 remote: jQuery.format("{0} is already in use")
  50.             }
  51.         },

  52.         // set this class to error-labels to indicate valid fields
  53.         success: function (label) {
  54.             // set   as text for IE
  55.             label.html(" ").addClass("checked");
  56.         }
  57.     });



  58. });

The HTML Code:
  1. <form class="form-horizontal well" id="signupform" action="#">
  2. <fieldset>
  3. <div class="control-group">
  4. <label class="control-label">First Name</label>
  5. <div class="controls">
  6. <input id="firstname" name="firstname" type="text" class="span2"/>
  7. </div>
  8. </div>
  9. <div class="control-group">
  10. <label class="control-label">Last Name</label>
  11. <div class="controls">
  12. <input id="lastname" name="lastname" type="text" class="span4">
  13. </div>
  14. </div>
  15. <div class="control-group">
  16. <label class="control-label">Username</label>
  17. <div class="controls">
  18. <input id="username" name="username" type="text" class="span6"/>
  19. </div>
  20. </div>
  21. <div class="control-group">
  22. <label class="control-label">Password</label>
  23. <div class="controls">
  24. <input id="password" name="password" type="password" class="span8"/>
  25. </div>
  26. </div>
  27. <div class="control-group">
  28. <label class="control-label">Confirm Password</label>
  29. <div class="controls">
  30. <input id="password_confirm" name="password_confirm" type="password" class="span8"/>
  31. </div>
  32. </div>
  33. <div class="control-group">
  34. <label class="control-label">Email Address</label>
  35. <div class="controls">
  36. <input id="email" name="email" type="text" class="span8"/>
  37. </div>
  38. </div>
  39. <div class="control-group">
  40. <div class="controls">
  41. <label id="lterms" for="terms">
  42. <input id="terms" type="checkbox" name="terms"/> I have read and accept the Terms of Use.</label>
  43. </div>
  44. </div>
  45. </fieldset>
  46. <div class="form-actions">
  47. <button class="btn btn-primary" type="submit">Save changes</button>
  48. <button class="btn">Cancel</button>
  49. </div>
  50. </form>

Using this scheme with the form name signupform everything goes smooth. The problem is that if I change the name.
For example:

Function File:
  1.     var validator = $("#registerform").validate({
The code File:
  1. <form class="form-horizontal well" id="registerform" action="#">

I only change the name and everything stops works ( all code in js file and html remains the same ).
I would like to get some help in solve this problem because I need more forms validated with custom fields, and none of them work.

Anyone could help please?