Javascript 只在firefox中关注下一个文本框
我写了一些代码来防止输入框在任何文本框中的值相同时失去焦点。这在chrome和ie中运行良好,但在firefox中它会失去焦点并转到下一个输入框。 这是我的代码,请提出建议Javascript 只在firefox中关注下一个文本框,javascript,jquery,Javascript,Jquery,我写了一些代码来防止输入框在任何文本框中的值相同时失去焦点。这在chrome和ie中运行良好,但在firefox中它会失去焦点并转到下一个输入框。 这是我的代码,请提出建议 $('.clsBarcode').bind("focusout", function (e) { var repeat = 0; if ($(this).val() != '') { var c = $(thi
$('.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个声誉,您的投票将更改公开显示的帖子分数。”