将其他字段输入值作为参数传递给jqueryFormvalidator

时间:2016-03-21 10:00:13

标签: jquery asp.net-mvc jquery-form-validator

我必须检查用户名和密码是否正确。 所以我想将用户名和密码作为参数传递给控制器​​中的函数。 我能够发送密码但无法发送密码。

<div class="control-field">
    <input type="text" id="ad-username" data-validation="required" data-validation-if-checked="isSecured" name="adusername" placeholder="AD Username"/>
</div>

<div class="control-field">
    <input type="text" id="ad-password" data-validation="required server"  name="adpassword"  placeholder ="AD Password" data-validation-url="/FormValidation/CheckPassword" />
</div>

控制器:

public JsonResult CheckPassword(string adusername, string adpassword) {

  FormValidator validator = new FormValidator();

  if (true) {
    validator.valid = false;
    validator.message = "User name and password did not match";
  }

  return Json(validator);

}

jQuery验证:

    $.validate(
  {
      modules: 'security',
      form: '#existing-form',
      validateOnBlur: false, // disable validation when input looses focus
      errorMessagePosition: 'element', // Instead of 'element' which is default
      scrollToTopOnError: false,// Set this property to true if you have a long form
      language: {
          requiredFields: "This field is required"
      }
  });

0 个答案:

没有答案