JQuery Validation错误消息fadein
JQuery Validation error message fadein
我需要你的帮助。我离解决方案不远了,但我如何才能让错误消息以淡入显示,而不是以正常方式显示。我已经有了这个代码,我想我已经非常接近解决方案了。
$(document).ready(function() {
$("#contactform").validate({
errorPlacement: function(error, element) {
error.fadeIn('.error');
},
messages: {
contactname: "Required",
email: "Invalid email",
comment: "Invalid URL"
}
});
});
代替:
error.fadeIn('.error');
尝试:
$('.error').text(error).fadeIn();
试试这个:
$(function() {
$("#contactForm").validate({
invalidHandler: function(form, validator) {
// not sure if this is the correct selector but I found it here: http://docs.jquery.com/Plugins/Validation/validate#toptions
$(".error").hide().fadeIn("slow");
},
messages: {
contactname: "Required",
email: "Invalid email",
comment: "Invalid URL"
}
});
});
您可以在消息下面的脚本中添加这样的部分
highlight: function (element, errorClass) {
$('label[for=' + element.id + ']').hide();
$('label[for=' + element.id + ']').fadeIn(5000);
},
jsfiddle中的代码不起作用。这是解决方案。
errorPlacement: function(error, element) {
var c = $("<span style='display: none'/>").append(error.html());
error.empty().append(c);
setTimeout(function(){ error.children().first().fadeIn("slow");},0);
}
@John Kalberer这对我来说很好。。。
谢谢,
$(函数(){$("#contactForm").validate({invalidHandler:函数(表单、验证器){//不确定这是否是正确的选择器,但我在这里找到了它:http://docs.jquery.com/Plugins/Validation/validate#toptions$(".error").hide().fadeIn("slow");},消息:{contactname:"必需",email:"无效电子邮件",comment:"无效URL"}});});
相关文章:
- Ajax聊天消息重复而不仅仅是更新
- Jquery FadeIn FadeOut 只工作一次
- 如果localstorage为空,则显示欢迎消息
- 绑定时将Parsley minlength消息作为选项传递时,未对其进行自定义
- 离开页面时弹出消息
- 有没有一种方法可以在控制台关闭的情况下让console.log()在IE中记录消息
- 消息显示之外的淘汰验证
- 选项卡侦听器未被来自后台脚本的消息激活
- jQuery在输入下验证post错误消息
- Scipt未在选定选项卡中执行以发送和接收消息
- 检查xmlhttprequest问题的消息
- AngularJs对ng消息的自定义替换
- ng消息仅在触摸时显示错误,并在错误的初始显示上转换
- 当用户按下回车键时,自动在text区域/text中插入消息
- 如果消息框答案为YES,则用Javascript填写表单
- 在javaservlet doPost方法中启动线程时,无法返回异常消息
- 解析云代码错误:解析.错误{代码:141,消息:“未调用成功/错误”}
- Node.js上的WebSocket,并在所有连接的客户端之间共享消息
- JQuery fadeIn()不工作,尽管正确的日志消息
- JQuery Validation错误消息fadein