jQuery验证:调用有效而不显示错误? [英] Jquery Validation: Call Valid without displaying errors?

查看:90
本文介绍了jQuery验证:调用有效而不显示错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JQuery Validation插件,我试图调用.valid()方法,而没有在屏幕上显示错误消息的副作用.我尝试了许多没有成功的方案,最近的是:

Using JQuery Validation plugin, I am trying to call the .valid() method without the side-effects of displaying error messages on screen. I have tried a number of scenarios with no success, my latest being:

$('#signup').validate({
            showErrors: function() { return; },
            errorElement: "",
            errorClass: "",
            errorPlacement: function() { },
            invalidHandler: function() { },
            highlight: function(element, errorClass) { },
            unhighlight: function(element, errorClass) { }
        });

$('#displayPurposes').text("Valid: " + $("#EMailAddress_EmailAddress").valid());

.valid()调用正常运行时,仍然会导致显示错误消息的副作用.

Whilst the .valid() call is working correctly it is still causing side-effects of displaying error messages.

我不希望发生这种情况,请帮忙.

I don't want this to happen, help please.

推荐答案

好吧,您可以使用CSS来强制"隐藏创建的错误消息元素,而不是尝试禁用该插件造成的任何错误放置.像这样:

Well instead of trying to disable any error placement made by the plugin you could use CSS to 'force' hiding the create error messages elements. Something like:

label.myvalidationclass { display: none !important; }

myvalidationclass是默认错误类别名称,也可以是您自己的名称.

Where myvalidationclass is either the default error class name or your own.

我知道这不是一个很好的解决方案,但我认为显示错误消息是该插件的核心功能之一.

I'm aware it is not a very nice solution but in my opinion, displaying error messages is one of the core feature of the plugin.

d.

这篇关于jQuery验证:调用有效而不显示错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆