var columnCommentsArray = new Array(); $("input[name='columnComments']").each( function(){ var columnComments = $(this).val(); if("" == columnComments) { flag = false; message += "字段名不能为空!<br/>"; return false; } else { if($.inArray(columnComments,columnCommentsArray) < 0){ columnCommentsArray.push(columnComments); } } } ) if(columnCommentsArray.length != columnCommentsCount) { flag = false; message += "存在相同的字段名,请修改!"; }