本文介绍了jQuery验证位置错误标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这对我也不起作用,当我尝试此操作时发生了错误:

and this also not worked for me an error occurd when I tried this:

error.insertBefore(element)
error.css('float','left')

或:

error.attr('style','float:left')

只有我可以添加以下属性:

only I can add these properties like this:

$(error).someproperty

这是我的代码,因为我在TFS上工作,因此无法复制粘贴,因此不允许复制/粘贴.问题是使用此代码,我无法显示float left错误消息.我希望该错误出现在文本框的左侧和下方.还有一件事,我只是在测试,所以在上面的图片中放入了float =right,所以就不用管它了. float:left也不起作用.我已经检查了.

This is my code as I can't copy paste because I work on TFS and copy/paste is not allowed. Problem is that with this code I can not float left error message. I want that error should appear on left and below the textbox. One thing more, I was just testing and I put float =right in picture above so forget about it. float:left is also not working. I have checked it.

推荐答案

根据文档rules('add', rules)只是添加 rules 及其消息的一种方法,仅此而已.您已经不当errorElement:wrapper:errorPlacement:放入了rules('add', rules)方法中.

As per the documentation, rules('add', rules) is only a method for adding your rules and their messages, nothing else. You've improperly placed errorElement:, wrapper:, and errorPlacement: within your rules('add', rules) method.

errorElement:wrapper:errorPlacement: 不是 rules.这些称为选项,因此只能放在 .validate(options) .

errorElement:, wrapper:, and errorPlacement: are not rules. These are called options and therefore would only be placed within .validate(options).

$(document).ready(function(){
    $('#myform').validate({
        errorElement: 'div',
        wrapper: 'div',
        errorPlacement: function(error, element) {
            error.insertAfter(element); // default function
        }
    });
});

否则,我不知道您要问的是什么,您应该将实际代码放入OP中,因此我们不必重新输入即可回答.

Otherwise, I don't know what you're asking and you should put your actual code within the OP, so we don't have to re-type it in order to answer.

这篇关于jQuery验证位置错误标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 18:31