Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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
Javascript 只在firefox中关注下一个文本框_Javascript_Jquery - Fatal编程技术网

Javascript 只在firefox中关注下一个文本框

Javascript 只在firefox中关注下一个文本框,javascript,jquery,Javascript,Jquery,我写了一些代码来防止输入框在任何文本框中的值相同时失去焦点。这在chrome和ie中运行良好,但在firefox中它会失去焦点并转到下一个输入框。 这是我的代码,请提出建议 $('.clsBarcode').bind("focusout", function (e) { var repeat = 0; if ($(this).val() != '') { var c = $(thi

我写了一些代码来防止输入框在任何文本框中的值相同时失去焦点。这在chrome和ie中运行良好,但在firefox中它会失去焦点并转到下一个输入框。 这是我的代码,请提出建议

    $('.clsBarcode').bind("focusout", function (e) {

                var repeat = 0;
                if ($(this).val() != '') {

                    var c = $(this).val();
                    $('.clsBarcode').each(function () {

                        if ($(this).val() == c)
                            repeat++;
                    });
                    if (repeat <= 1) {
                        saveflag = false;
                        return;

                    }
                    else {
                        alert("Barcode value exist,Please select different Barcode");
                        $(this).css('border', '2px solid red');
                        $(this).focus();
                        e.preventDefault();

                    }
                }
                else {
                    $(this).css('border', '');

                }


            });
$('.clsBarcode').bind(“focusout”,函数(e){
var-repeat=0;
if($(this.val()!=“”){
var c=$(this.val();
$('.clsBarcode')。每个(函数(){
if($(this).val()==c)
重复++;
});

如果(重复请从这里的JSFIDLE链接找到解决方案。这将在Internet explorer和firefox中工作。
更改了您的脚本,如下所示

$('.clsBarcode').each(function () {

   if ($(this).val() == c)https://jsfiddle.net/fb3Lq9qq/28/#run
         repeat++;
     });
   if (repeat <= 1)
    {
        saveflag = false;
        return;

     }
   else {
         alert("Barcode value exist,Please select different Barcode");
         $(this).css('border', '2px solid red');
         var textgroupid= $(this).attr("id");
         setTimeout(function()
         {
             $("#"+ textgroupid +"").focus();
         },10); 
        }
       }
  else {
         $(this).css('border', '');
         //$('#BtnBarcodesave').prop('disabled', false);
       }
       });         
    });
$('.clsBarcode')。每个(函数(){
if($(this).val()==c)https://jsfiddle.net/fb3Lq9qq/28/#run
重复++;
});

如果(重复请从这里的JSFIDLE链接找到解决方案。这将在Internet explorer和firefox中工作。
更改了您的脚本,如下所示

$('.clsBarcode').each(function () {

   if ($(this).val() == c)https://jsfiddle.net/fb3Lq9qq/28/#run
         repeat++;
     });
   if (repeat <= 1)
    {
        saveflag = false;
        return;

     }
   else {
         alert("Barcode value exist,Please select different Barcode");
         $(this).css('border', '2px solid red');
         var textgroupid= $(this).attr("id");
         setTimeout(function()
         {
             $("#"+ textgroupid +"").focus();
         },10); 
        }
       }
  else {
         $(this).css('border', '');
         //$('#BtnBarcodesave').prop('disabled', false);
       }
       });         
    });
$('.clsBarcode')。每个(函数(){
if($(this).val()==c)https://jsfiddle.net/fb3Lq9qq/28/#run
重复++;
});

如果(重复)你会提供jsfiddle-link吗jsfiddle-link请在下面找到答案。你会提供jsfiddle-link吗jsfiddle-link请在下面找到答案。我做了,但它说:“谢谢你的反馈!一旦你赢得了总共15个声誉,你的投票将改变公开显示的帖子分数。”我做了,但它说“感谢您的反馈!一旦您赢得总共15个声誉,您的投票将更改公开显示的帖子分数。”