开发者

Using jQuery Validate to ensure there is at least one row in my table

I am using a table in an entry program to allow the user to add one or more rows of information (much like this article).

I need to ensure that there is at least one row in this table. Google is not really turning much up for me on people doing this. Can anyone give me direction on this? Can I do a count based on a class name? 开发者_JAVA技巧

Here is the layout of my table:

<table id="editorRows">
    ...
    <tbody class="editorRow">
        <tr class="row1">
        </tr>
        <tr class="row2" style="display: none;">
        </tr>
        <tr class="row3" style="display:none;">
        </tr>
    </tbody>
</table>

A "row" in this case is the tag. Row 2 and 3 get dynamically showen based on options in row 1.


you can use $("#editorRows tr").length > 0

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜