0

我希望我想做的事情是有意义的。我有以下表格。字段在表中。

<form method="POST">
    <table class="FormFieldList" cellspacing="4">
        <tr>
            <td><span class="Required">*</span></td>
            <td><label for="FirstName">First Name</label></td>
            <td>:</td>
            <td><input type="text" inputChars="AN" inputReq="1" name="FirstName" inputMin="3" id="FirstName" size="40" maxlength="100" /></td>
            <td><span class="InputHelp">11</span></td>
            <td><span class="InputError">22</span></td>         
        </tr>
        </table>
</form>

这些字段需要符合某些标准。该字段具有以下被检查的属性:inputMin="3"。如果输入长度小于,那么我想在 22 中显示错误。

我的脚本看起来像这样并且效果很好....到目前为止:

$(':input').blur(function(event) {  

if ($(this).attr("inputMin")!="")
{
    var id = $(this).attr("id");
    if ($(this).attr("inputMin")>$(this).val().length)
    {
        var Label=$('label[for="'+id+'"]').html();
        var Min=$(this).attr("inputMin");
        alert(Label+" needs a minimum of "+Min+" characters.")


        //NEED THIS HERE SO I CAN DISPLAY AN ERROR
        alert( $('table.FormFieldList td:last input[name='+id+']').val() )



        $(this).focus();
    };
};

});

有什么建议吗?

感谢您的帮助。

4

1 回答 1

0

$(this).closest('tr').find('td:last span')会给你当前行span的最后一个内部。td

于 2011-06-10T01:02:11.167 回答