validation动态添加的文本框

在下面的代码中,如何仅为动态添加的文本框validation空值,即r_score1,r_score2 ………

 function validate() { //How to validate the r_Score.. textfields } $(document).ready(function() { for(var i=0;i< sen.length;i++) { row += ''; } $('#details').append(row); });  

为文本框指定一个类名并使用类选择器

 function validate() { var boxes = $("#details input:text.classname"); boxes.each(function(){ var currentVal = $(this).val(); // do your validation here }); } 
 $("#details input[name^='r_score']").each(function(nr){ if($(this).val() === "") alert("Field "+(nr+1)+" is empty"); }); 

使用实时事件处理程序来动态添加内容。