Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我可以抑制来自jquery验证的消息,但仍然让它应用新的背景颜色吗?_Jquery_Validation_Jquery Mobile - Fatal编程技术网

我可以抑制来自jquery验证的消息,但仍然让它应用新的背景颜色吗?

我可以抑制来自jquery验证的消息,但仍然让它应用新的背景颜色吗?,jquery,validation,jquery-mobile,Jquery,Validation,Jquery Mobile,现在我们有了占位符属性,可以很好地说明输入字段中应该输入什么,并且考虑到移动电话上的空间非常宝贵,我想知道是否有一种方法可以让jqueryvalidate简单地设置输入字段的背景色,以指示它们是否有效。由于我使用jQuery mobile,我的大多数输入(包括单选按钮组)都在容器中,所以我想在不发出错误消息的情况下将“ui字段包含错误”类背景设置为颜色(我在css中定义的颜色)是我想做的。可能吗 TIA这就是我最后想到的。重写highlight和unhighlight方法允许我向输入的容器中添加

现在我们有了占位符属性,可以很好地说明输入字段中应该输入什么,并且考虑到移动电话上的空间非常宝贵,我想知道是否有一种方法可以让jqueryvalidate简单地设置输入字段的背景色,以指示它们是否有效。由于我使用jQuery mobile,我的大多数输入(包括单选按钮组)都在容器中,所以我想在不发出错误消息的情况下将“ui字段包含错误”类背景设置为颜色(我在css中定义的颜色)是我想做的。可能吗


TIA

这就是我最后想到的。重写highlight和unhighlight方法允许我向输入的容器中添加一个适当的类,并根据自己的喜好高亮显示它们——最后我决定使用红色或绿色边框。最后,我选择保留错误文本并以工具提示的方式显示它

$(".product_type_form").validate({
    validClass: "data-valid", 
    errorClass: "data_invalid",
    errorElement: "span",                     
    errorPlacement: function(error, element) {
        if ($(element).is("input[type='radio']")) {
            container = $(element).parents('div.ui-controlgroup-controls');
        } else {
            container = $(element).parents('div.ui-input-text');
        }             
        error.insertBefore(container);
    },
    highlight: function(element, errorClass, validClass) {
        if ($(element).is("input[type='radio']")) {
            container = $(element).parents('div.ui-controlgroup-controls');    
        } else {
            container = $(element).parents('div.ui-input-text');
        }
        container.addClass(errorClass);
        container.removeClass(validClass);
    },
    unhighlight: function (element, errorClass, validClass) {
        if ($(element).is("input[type='radio']")) {
            container = $(element).parents('div.ui-controlgroup-controls');    
        } else {
            container = $(element).parents('div.ui-input-text');
        }            
        container.addClass(validClass);
        container.removeClass(errorClass);            
    }
});