相关疑难解决方法(0)

如何在Tooltipster工具提示中显示来自jQuery Validate插件的消息?

我想使用Tooltipster插件来显示jQuery Validate插件生成的表单错误.

jQuery for Validate插件:

$(document).ready(function () {

    $('#myform').validate({ // initialize jQuery Validate
        // other options,
        rules: {
            field1: {
                required: true,
                email: true
            },
            field2: {
                required: true,
                minlength: 5
            }
        }
    });

});
Run Code Online (Sandbox Code Playgroud)

jQuery for Tooltipster插件:

$(document).ready(function () {

    $('.tooltip').tooltipster({ /* options */ });  // initialize tooltipster

});
Run Code Online (Sandbox Code Playgroud)

HTML:

<form id="myform">
    <input type="text" name="field1" />
    <input type="text" name="field2" />
    <br/>
    <input type="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)

我如何整合这两个jQuery插件的使用,以便验证错误出现在工具提示中?

jquery tooltip jquery-validate tooltipster

19
推荐指数
1
解决办法
5万
查看次数

jQuery表单验证 - 错误标签的CSS

我使用jquery网站上使用的完全相同的示例进行简单的表单验证; http://docs.jquery.com/Plugins/Validation

但有一点我不明白,示例中的错误消息显示在每个输入字段的右侧.我想在每个输入字段下显示错误.这是如何运作的?我尝试了宽度和填充,但到目前为止没有运气.

我使用的CSS代码略有改动,但仍然非常简单;

label { width: 10em; float: left; }
label.error { float: none; color: red; padding-left: 0px; vertical-align: bottom; }
p { clear: both; }
fieldset {position: absolute; left: 450px; width: 400px; } 
em { font-weight: bold; padding-right: 1em; vertical-align: top; }
Run Code Online (Sandbox Code Playgroud)

这是jfiddle http://jsfiddle.net/nBv7v/

css jquery jquery-validate

6
推荐指数
2
解决办法
5万
查看次数

标签 统计

jquery ×2

jquery-validate ×2

css ×1

tooltip ×1

tooltipster ×1