Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery查找匹配表单条目_Jquery_Forms_Field_Match - Fatal编程技术网

Jquery查找匹配表单条目

Jquery查找匹配表单条目,jquery,forms,field,match,Jquery,Forms,Field,Match,我有一个在列中有多个输入字段的表单 当用户在字段中输入ID时,我想检查另一个字段是否具有相同的ID条目 我正在使用focusout进行此操作,并使用匹配类查看所有字段,但我当前离开的字段除外 这就是我到目前为止所做的: <table> <tbody> <tr><th>ID</th></tr> <tr><td><input type='text' name='uid[]' id='uid' cla

我有一个在列中有多个输入字段的表单

当用户在字段中输入ID时,我想检查另一个字段是否具有相同的ID条目

我正在使用focusout进行此操作,并使用匹配类查看所有字段,但我当前离开的字段除外

这就是我到目前为止所做的:

<table>
<tbody>
<tr><th>ID</th></tr>
<tr><td><input type='text' name='uid[]' id='uid' class='uid' value='213'></td></tr>
<tr><td><input type='text' name='uid[]' id='uid' class='uid' value='456'></td></tr>
<tr><td><input type='text' name='uid[]' id='uid' class='uid' value='951'></td></tr>
</tbody>
</table>


$('input[class="uid"]').focusout(function () {
    var check = ($(this)).val();

    $('input[class="uid"]').not($(this)).each(function(index){ 
        var test = $(this).val();
        if (check = test) alert('Match'); 
        });
 });

身份证件
$('input[class=“uid”]”)。focusout(函数(){
var check=($(this)).val();
$('input[class=“uid”]”)。不是($(this))。每个(函数(索引){
var test=$(this.val();
如果(检查=测试)警报(“匹配”);
});
});
我创建了一个来显示这一点

我的问题是每个条目都会显示匹配,而不仅仅是匹配条目

我做错了什么?如何使用刚编辑的字段中的值与同一类的所有其他字段进行匹配

也可以突出显示两个匹配字段吗?然后在它们不再匹配时清除它们


谢谢

您应该使用
==
而不是
=
进行比较

而且

  $('input[class="uid"]').not($(this)) 
可以替换为

$('.uid').not($(this))

您应该使用
==
进行比较


但是你得到了一个无止境的循环。

只要把单个“=”改为“=”。你会得到结果的。

谢谢,这似乎很有效。是否可以高亮显示两个匹配字段?原来的帖子更新了。