jQuery(function($){    
    $(".chama-form").validate({
        rules: {
            chama_password: "required",
            chama_password_confirm: {
            equalTo: "#password"
          }
        }
      });
      $( 'body' ).on( 'keyup', 'input[name=chama_password], input[name=chama_password_confirm]', function( event ) {
        wdmChkPwdStrength(
            // password field
            $('input[name=chama_password]'),
            // confirm password field
            $('input[name=chama_password_confirm]'),
            // strength status
            $('#password-strength'),
           // Submit button
           $('input[type=submit]'),
           // blacklisted words which should not be a part of the password
           ['admin', 'happy', 'hello', '1234']
        );
      });
    
});

function wdmChkPwdStrength( $pwd,  $confirmPwd, $strengthStatus, $submitBtn, blacklistedWords ) {
  var pwd = $pwd.val();
  var confirmPwd = $confirmPwd.val();

  // extend the blacklisted words array with those from the site data
  blacklistedWords = blacklistedWords.concat( wp.passwordStrength.userInputBlacklist() )

  // every time a letter is typed, reset the submit button and the strength meter status
  // disable the submit button
  $submitBtn.attr( 'disabled', 'disabled' );
  $submitBtn.addClass( 'chama-disabled-button' );
  $strengthStatus.removeClass( 'chama-short chama-mismatch chama-bad chama-good chama-strong' );

  // calculate the password strength
  var pwdStrength = wp.passwordStrength.meter( pwd, blacklistedWords, confirmPwd );

  switch ( pwdStrength ) {

    case 2:
    $strengthStatus.addClass( 'chama-bad' ).html( pwsL10n.bad );
    break;

    case 3:
    $strengthStatus.addClass( 'chama-good' ).html( pwsL10n.good );
    break;

    case 4:
    $strengthStatus.addClass( 'chama-strong' ).html( pwsL10n.strong );
    break;

    case 5:
    $strengthStatus.addClass( 'chama-mismatch' ).html( pwsL10n.mismatch );
    break;

    default:
    $strengthStatus.addClass( 'chama-short' ).html( pwsL10n.short );

}
// set the status of the submit button
if ( (3 === pwdStrength || 4 === pwdStrength) && '' !== confirmPwd.trim() ) {
  $submitBtn.removeAttr( 'disabled' );
  $submitBtn.removeClass( 'chama-disabled-button' );
}

return pwdStrength;
}