小编Joh*_*ohn的帖子

使用JQuery Validation插件获取重复的错误消息

我是JQuery和Validation插件的新手.

简短说明:我希望我的所有错误消息都显示在表单顶部的一个div中,而不是显示在每个标签旁边.经过一番小小的搜索和网络搜索之后,我想出了以下内容,它有效,但是sourceurl:消息在验证时出现了两次.我不知道为什么.任何帮助,将不胜感激.干杯,约翰

源代码:

<form name="siteauth" id="siteauth" action="savedata" type="POST">
    <div class="message"></div>
    <fieldset>
        <label>Short Description:</label>
        <br><input id="shortdescription" size="75" type="text" maxlength="50"  name="shortdescription"/>
        <br><label>Source URL:</label>
        <br><input id ="sourceurl" size="75" type="text" maxlength="500"  name="sourceurl"/>
        <br><label>Callback URL:</label>
        <br><input id="callbackurl"  size="75" type="text" maxlength="500" name="callbackurl"/>
        <br><label>Callback Content:</label>
        <br><input id="in4"  size="75" type="text" maxlength="100" name="callbackcontent"/>
        <br>
        <br><input type="submit" value="Add"/>
    </fieldset>
</form>

<script src="http://code.jquery.com/jquery-latest.js"></script>
 <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script>


<script>

    $(document).ready(function(){
        $("#siteauth").validate({
            rules: {
                shortdescription: "required",
                sourceurl: "required"
            },
            messages: {
                shortdescription: "Enter a short description. ",
                sourceurl: "Enter a Source URL. "
            }, …
Run Code Online (Sandbox Code Playgroud)

validation jquery plugins jquery-validate

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

为什么表单元格中有2个href元素时有额外的间距

图片胜过千言万语.注意最后一行和其余行之间的空格.

在此输入图像描述

这是代码.

<html>
<head></head>
<style type="text/css">
td a {
text-decoration: none;
color: black;
font-size:11px;
font-family: Arial, 
}
</style>
<body>
<table>
    <tr>
        <td width="120px"><a href="#" target="__blank">Now is the time for all good men to come to the aide of their country said the quick brown fox to the lazy cow.</a> <a href="#" target="__blank">Moo</a></td>
    </tr>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

如果我取出第二个标签并在第一个标签中包含Moo文本,则间距消失.这里发生了什么?

html css html-table

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

标签 统计

css ×1

html ×1

html-table ×1

jquery ×1

jquery-validate ×1

plugins ×1

validation ×1