jQuery 验证 errorPlacement 的自定义动画
好的,我有一个包含 1 个必填字段的表格。这是验证代码:
$('#form').validate({
rules: {
email: {
required: true,
email: true
}
},
messages: {
email: "Please enter a valid email address."
},
errorPlacement: function(error, element) {
error.appendTo(element.parent()).hide().fadeIn;
}
});
这很棒,但我希望动画具有下滑的风格。这就提出了一个有趣的观点:尝试删除 fadeIn,它甚至不会隐藏该元素。一旦错误被纠正,我希望它滑走,成功提交后,我希望一条成功消息滑落。我可以寻求帮助吗?我见过很多人提出了不起作用的建议,但没有真正的修复建议。
OK so I have a form with 1 required field. This is the validation code:
$('#form').validate({
rules: {
email: {
required: true,
email: true
}
},
messages: {
email: "Please enter a valid email address."
},
errorPlacement: function(error, element) {
error.appendTo(element.parent()).hide().fadeIn;
}
});
This is great, except I want the animation to be of a slidedown flavor. Which brings up an interesting point: trying to remove the fadeIn, it doesn't even hide the element. Once the error is corrected, I want it to slide away, and upon successful submission, I want a success message to slideDown. Can I get some help? I've seen a lot of people suggest non-working stuff but no real suggestion for a fix.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
至于成功部分,请将 SlideDown() 功能添加到验证调用中的成功选项中。
至于 fadeIn - 我不确定整行看起来是否正确,但在
fadeIn()
之后至少缺少一些括号;As for the success piece, add your slideDown() funcationality to the success option within your call to validate.
As for the fadeIn - I am not certain that entire line looks correct, but straight off it is at least missing some parentheses after
fadeIn()
;