如何在jQuery验证插件中隐藏div

问题描述 投票:0回答:1

我正在使用jquery验证来验证注册表单。一切正常。但是在输入类型的密码下面,id为password_msg的范围内有一条消息。此消息显示在提交表单之前。现在,密码验证消息中也出现了相同的消息。当我单击提交时,这两个消息都会显示。我需要在单击“提交”时将其隐藏,该消息位于id为[[password_msg)的span的密码标签下面。仅显示验证消息。

<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(); }); });

但同时出现两个消息。
jquery validation jquery-validate
1个回答
0
投票
我不明白您的问题,但是解决方法可以是以下代码

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

© www.soinside.com 2019 - 2024. All rights reserved.