-1

我正在使用 jquery 验证来验证注册表单。一切正常。但是在输入类型密码下面有一条消息,id 为password_msg。此消息显示在提交表单之前。现在同样的消息也在密码验证消息中。当我点击提交时,两条消息都会显示。当我单击提交时,我需要,然后应该隐藏位于跨度中密码标签下方的 ID 为password_msg的消息。仅应显示验证消息。

<input name="password" class="form-control" type="password" id="password" placeholder="************">
  <span class="font-13 text-danger" id="password_msg">
    Password should be a minimum of 8 characters including uppercase and lowercase letters, at least 1 number and at least 1 special character (!@#$%^&*).
  </span>
 <div class="col-md-6 col-sm-5 col-xs-6 text-left">
   <button type="submit" class="next_button" name="reg_user">Sign up</button>
 </div>

我的jQuery是:

$('form[id="validate_form"]').validate({
rules: {
  password: {
        required: true,
            }
 },
messages: {
   ,
    password: {
      required: 'Password should be a minimum of 8 characters including uppercase and lowercase letters, at least 1 number and at least 1 special character (!@#$%^&*).',
               }
 },
  submitHandler: function(form) {
    form.submit();
  }
});

我试图隐藏消息:

$(document).ready(function(){
$('#reg_user').on('click', function(event) {
    $('#password_msg').hide();
});
});

但是两条消息都出现了。

4

1 回答 1

1

我不明白你的问题,但修复可以是下面的代码

$(document).ready(function(){
$('.next_button').on('click', function(event) {
    $('#password_msg').hide();
});
})
于 2020-05-27T06:40:27.353 回答