入力ステートメントを検証しようとしていますが、入力が間違っている場合、ユーザーは入力が正しくないことを通知する Bubble Div を受け取ります。エラーが発生した入力要素にフォーカスを戻し、その中のテキストを選択しようとしています。コードは Chrome では機能しますが、Firefox では機能しません。誰でもこれで私を助けることができますか?. ここにコードを投稿しています:
$("#inner-tbl").on('blur', 'input[type=text]', function(e) {
var checkval = $(this).val();
checkval = checkval.replace(/\s/g,'');
$(this).val(checkval);
console.log(checkval);
var numericReg = /^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$/;
if(!numericReg.test(checkval)) {
$(this).addClass("error");
$(this).focus().select();
console.log("Not an integer");
var ip_width, ip_height, x;
ip_width = $(this).outerWidth();
ip_height = $(this).outerHeight();
x = $(this).offset();
console.log("Width :"+ip_width+" Height :"+ip_height+" Top :"+x.top+" Left :"+x.left);
$("body").append("<div class='error_bubble'><span class='errordiv'>Numeric value.</span></div>");
$(".error_bubble").css({
position: 'absolute',
top: (x.top+30)+'px',
left: (x.left-30)+'px'
});
}
});
これがjsfiddleです:http://jsfiddle.net/neoragex/Wk35w/