Javascript 无法使用jquery在文本框中允许重复条目

Javascript 无法使用jquery在文本框中允许重复条目,javascript,jquery,Javascript,Jquery,我有一个文本框在每一行有相同的名称像这样 <tr> <g:textField name ="point" value = "" class = "destination_points" id ="point_0" /> <input type ="hidden" value ="" name ="pointDistanceMapping.point.id" id ="point_id_0" class="point_id"/> <

我有一个文本框在每一行有相同的名称像这样

 <tr>
    <g:textField name ="point" value = "" class = "destination_points"  id ="point_0" />
   <input type ="hidden" value ="" name ="pointDistanceMapping.point.id" id ="point_id_0" class="point_id"/>   
 </tr> 
 <tr>
    <g:textField name ="point" value = "" class = "destination_points"  id ="point_1" />
    <input type ="hidden" value ="" name ="pointDistanceMapping.point.id" id ="point_id_1" class="point_id"/>
 </tr>
  <tr>


我必须验证这些文本框不应该有相同的值,所以我如何使用jquery来实现…

看看这个提琴


您可以一次添加一个数组中的所有值,并在添加之前检查它是否存在。看看这个


是的,我已经试过了。每个功能都很好用。你可能想发布你的代码,以便对其进行改进/修复。为什么不能使用IDs?它们是不同的。我有更多的行数(超过数百行),所以这个方法对我来说不是一个好方法。。。我需要一些方法,通过所有的文本框,其中有名称“点”或类“目的地点”(因为他们是相同的)循环,并找出是否有重复我有更多的行数(超过数百),所以这个方法对我来说不是一个好方法。。。我需要一些方法,通过所有的文本框,其中有名称“点”或类“目的地点”(因为它们是相同的)循环,并找出是否有重复
$('#checkDup').click(function() {

    var textValues = new Array();
    $("input.destination_points").each(function() {

        doesExisit = ($.inArray($(this).val(), textValues) == -1) ? false : true;
        console.log(textValues)
        if (!doesExisit) {
            textValues.push($(this).val())
        } else {
            alert('dup');
            return false;
        }
    });
});