title: Custom Regex Validator in Parsley.js
body: <p><strong>Issue</strong></p>
  
  <p>I am having a problem creating a custom validator for the Parsley.js plugin. What I'm trying to do is test a value vs a regex. Specifically, I'm trying to validate that a password value includes at least one uppercase and one lowercase letter. The validation code throws an error, but does not return true when the condition has been satisfied. </p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form name="Form" id="signupform" method="post" action="#" data-parsley-validate data-parsley-excluded="input[type=button], input[type=submit], input[type=reset], input[type=hidden], [disabled], :hidden"&gt;
        &lt;label for="password1"&gt;New Password &lt;span class="req"&gt;*&lt;/span&gt;&lt;/label&gt;
        &lt;input name="password" id="password1" type="password" class="password" data-parsley-minlength="1" data-parsley-errors-container=".errorspannewpassinput" data-parsley-required-message="Please enter your new password." data-parsley-mixedcase="^(?=.*[a-z])(?=.*[A-Z]).*$" data-parsley-required/&gt;
        &lt;span class="errorspannewpassinput"&gt;&lt;/span&gt;
        &lt;label for="confirm_password1"&gt;Confirm Password &lt;span class="req"&gt;*   &lt;/span&gt;&lt;/label&gt;
        &lt;input name="Password_2" id="password2" type="password" class="password" data-parsley-minlength="1" data-parsley-errors-container=".errorspanconfirmnewpassinput" data-parsley-required-message="Please re-enter your new password." data-parsley-equalto="#password1" data-parsley-mixedcase="^(?=.*[a-z])(?=.*[A-Z]).*$" data-parsley-required /&gt;
        &lt;span class="errorspanconfirmnewpassinput"&gt;&lt;/span&gt;
        &lt;input type="submit" name="submitinfo" id="submitsignup" data-theme="b" style="width:100%;" alt="Sign Up Now" value="Submit Account Request" /&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p><strong>jQuery</strong></p>
  
  <pre><code>  $(function() {
      // Set variables
      var pmixedCase = 'Y';
      var mixedCase = $('.mixedcase');
      var passwordField = $('#password1, #password2');
      var passwordFieldErrors = $('.errorspannewpassinput, .errorspanconfirmnewpassinput');
      // Assemble list of visible password requirements
      // Mixed Case
      if (pmixedCase === 'Y') {
          mixedCase.show();
      } else {
          mixedCase.hide();
      }
      // Custom Validators
      window.Parsley.addValidator('mixedcase', {
          requirementType: 'regexp',
          validateString: function(value, requirement) {
              return requirement.test(value);
          },
          messages: {
              en: 'Your password must contain at least (1) lowercase and (1) uppercase letter.'
          }
      });
  }); 
  </code></pre>
  
  <p>I've included a JSFiddle below.</p>
  
  <p><a href="http://jsfiddle.net/Ltv4L5s2/7/" rel="nofollow">Fiddle</a></p>