0

jQuery Validate は機能しています (必要な電子メール フィールドが空の場合にエラーがトリガーされます) が、submitHandler 内のコードはトリガーされません (アラートは表示されません)。また、submitHandler が機能していないため、フォームが secure/process_login.php に投稿されるとは思いません。動作していない alert() の後ですが、検証された場合は動作します。

フォームコード:

<form action="secure/process_login.php" method="post" id="login_form" name="login_form">
  <fieldset>
    <legend>Log In</legend>
    <div class="form-group">
      <label for="inputEmail">Email address</label>
      <input type="text" id="email" class="form-control" name="email"placeholder="Your Email Address" required>
    </div>
    <div class="form-group">
      <label for="inputPassword">Password</label>
      <input type="password" class="form-control" name="password" id="password" placeholder="Your Password">
      <input type="hidden" name="p" id="p" value="">
    </div>
    <button type="submit" class="btn btn-primary form-control">Log In</button>
  </fieldset>
</form>

脚本:

<script>
  $("#login_form").validate({
  submitHandler: {
    function formhash(form, password) {
       // Create a new element input, this will be out hashed password field.
       var p = document.createElement("input");
       // Add the new element to our form.
       form.appendChild(p);
       p.name = "p";
       p.type = "hidden"
       p.value = hex_sha512(password.value);
       // Make sure the plaintext password doesn't get sent.
       password.value = "";
       // Finally submit the form.
       alert("Test");
       form.submit();
    }
  }
  });
</script>
4

2 に答える 2