我有一个表有一行动态文本框.示例如下:

我通过单击[+]添加新目标在表格中添加行,它将出现在屏幕下方:

我想将验证类添加到表格内的所有文本框中.因此,当用户单击"保存"按钮时,它将检查所有文本框.
我尝试使用这个jquery:
$('#tbTargetDetails tr').each(function () {
$(this).find('td input:text').each(function (i,a) {
// get each of the textbox and add validation class to it
});
});
Run Code Online (Sandbox Code Playgroud)
我正在使用MVC 5,jquery-1.10.2.js,jquery-1.10.2.min.js,jquery.validate*和Site.css,它们具有类input.input-validation-error
在我的模特中:
public class ClsTargetInfo
{
public string ItemNumber_Target { get; set; }
[Required]
public string TargetColor_U { get; set; }
[Required]
public string TargetColor_V { get; set; }
[Required]
public string D90Target_U { get; set; }
[Required]
public string D90Target_V { get; set; }
[Required]
public string D10Target_U { get; set; …Run Code Online (Sandbox Code Playgroud)