3

我有一个 iOS 应用程序,并且使用 Parse.com,我可以允许用户在他们忘记使用 Parse.com API 时重置他们的应用程序。问题在于,当用户重置密码时,无法强制执行密码标准(或者至少我还没有找到方法),甚至没有其他字段来验证您输入的密码是否正确。我想知道是否有人对此有解决方案。

我的情况完全正确:当您输入重置密码时,我可以应用最低标准,例如 1 个大写字母、1 个数字和 1 个小写字母吗?此外,在下方有一个验证密码字段。

我尝试进行客户端 JS 验证,但没有成功。我已经包含了下面的代码块。谢谢!!!!

HTML

<div class="row">
<div class="medium-6 medium-offset-3 small-10 small-offset-1 columns">
  <form id='form' action='#' method='POST'>
    <label>New Password for <span id='username_label'></span></label>
    <input name="new_password" type="password" />
    <input name='utf-8' type='hidden' value='✓' />
    <input name="username" id="username" type="hidden" />
    <input name="token" id="token" type="hidden" />
    <button>Change Password</button>
  </form>
</div>

JS

<script language='javascript' type='text/javascript'>
<!--
window.onload = function() {
  var urlParams = {};
  (function () {
      var pair, // Really a match. Index 0 is the full match; 1 & 2 are the key & val.
          tokenize = /([^&=]+)=?([^&]*)/g,
          // decodeURIComponents escapes everything but will leave +s that should be ' '
          re_space = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); },
          // Substring to cut off the leading '?'
          querystring = window.location.search.substring(1);

      while (pair = tokenize.exec(querystring))
         urlParams[re_space(pair[1])] = re_space(pair[2]);
  })();

  var base = 'https://www.parse.com';
  var id = urlParams['id'];
  document.getElementById('form').setAttribute('action', base + '/apps/' + id + '/request_password_reset');
  document.getElementById('username').value = urlParams['username'];
  document.getElementById('username_label').appendChild(document.createTextNode(urlParams['username']));

  document.getElementById('token').value = urlParams['token'];
  if (urlParams['error']) {
    document.getElementById('error').appendChild(document.createTextNode(urlParams['error']));
  }
  if (urlParams['app']) {
    document.getElementById('app').appendChild(document.createTextNode(' for ' + urlParams['app']));
  }

}

$(function() {
$('#form').submit(function() {
    if (document.getElementById('new_password').length == 2)
    {
      // something is wrong
      alert('There is a problem with the first field');
      return false;
    }
    else {
      return true;
    }
  });

});

//-->

4

0 回答 0