gpt4 book ai didi

jquery - 为什么输入有效时表单不会消失?(jquery 验证插件)

转载 作者:行者123 更新时间:2023-12-01 05:59:12 25 4
gpt4 key购买 nike

我在表单上显示错误,但即使表单有效(我的表单带有背景和边框) - 它也不会消失。

这是屏幕截图:

这是我的js:

 $(".login").validate({
rules: {

"user[email]":{
email: true,
required: true
},
'user[password]': {
required: true,
minlength: 6,
remote: {
url: "http://127.0.0.1:3000/checkpass",
//url: "http://91.228.126.168:3000/checkpass",
type: "get",
data: {
email: function() { return $("#user_email").val(); }
}
}
}
},
messages: {
"user[password]": {
remote: "You entered wrong credentials"}
},
errorContainer: "#messageBox1",
errorLabelContainer: "#messageBox1 ul",
wrapper: "li"

})

CSS:

  #messageBox1{
display: none;
}

#messageBox1{
width: 280px;
padding: 20px 0 20px 20px;
border-radius: 5px;
background: rgb(252, 248, 227) ;
border: solid 1px rgb(192, 152, 83);
margin-bottom: 10px;
}

我该如何解决这个问题?

最佳答案

我不确定您正在使用什么验证插件,但它似乎可以控制您的标记(如果我错了,请纠正我)。

如果您愿意使用其他验证插件(独立于标记结构),请尝试 jQuery Validator

请参阅演示和文档以了解操作方法。 README 包含参数信息。

[免责声明:我开发了这个插件供内部使用,但我们今天才将其开源]

以下是我如何使用此插件处理您的案例:

if($("#yourForm INPUT").Validate()){
$("#messageBos1").hide();
} else {
$("#messageBos1").show();
}

当然,你应该根据自己的需要进行修改,再次查看文档和演示。

关于jquery - 为什么输入有效时表单不会消失?(jquery 验证插件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12817445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com