1

使用jquery 验证插件

见:http: //jsfiddle.net/Kn3v5/205/

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<div>
    <form id="everything">
        <label for="dd1">Select the best option</label>
        <br/>
        <select name="dd1" id="dd1" class="required">
            <option value="">None</option>
            <option value="o1">option 1</option>
            <option value="o2">option 2</option>
            <option value="o3">option 3</option>
        </select>
        <br/>
        <br/>
        <input id="agreement" name="agreement" type="checkbox"><b> I accept the TOS</b>
            <br/>
        <input type="submit" />
</div>
</form>

我有多个字段在其右侧显示错误消息。我的问题是,复选框的验证消息出现在复选框及其标签之间。

[复选框]

          [validation message] [label]

但我想要这样:

[复选框] - [标签]

[验证消息]

我怎样才能做到这一点?提前致谢!

4

2 回答 2

0

小提琴 添加 float:left 到复选框并使用文本框切换消息

 <label  for='agreement'> I accept the TOS</label>
    <input id="agreement" name="agreement" type="checkbox" style = 'float:left' />

        <br/>
    <input type="submit" />
于 2013-06-06T02:19:06.607 回答
0

这就是我正在寻找的 http://jsfiddle.net/Kn3v5/223/

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<div>
    <form id="everything">
        <label for="dd1">Select the best option</label>
        <br/>
        <select name="dd1" id="dd1" class="required">
            <option value="">None</option>
            <option value="o1">option 1</option>
            <option value="o2">option 2</option>
            <option value="o3">option 3</option>
        </select>
        <br/><br/>
        <label for='agreement'>I accept the TOS</label>
        <input id="agreement" name="agreement" type="checkbox" style='float:left' />
        <br/>
        <div id="everything2"></div>
        <input type="submit" />
    </form>
</div>
于 2013-06-10T04:12:43.460 回答