//if scan field exists then focus the field after every second
if($('.focus-me').length > 0){
setInterval(function(){
$('.focus-me').focus();
},1000);
//if scan field is not focused then hide "scanner ready" message
$(".focus-me").focusout(function(){
$('.focus-in').hide();
$('.focus-out').fadeIn(500);
});
//if scan field is focused then hide "scanner not ready" message
$(".focus-me").focusin(function(){
$('.focus-out').hide();
$('.focus-in').fadeIn(500);
});
//reset the field
$(document).on('keyup',function(e){
if (e.key === ' ' || e.key === 'Spacebar') {
e.preventDefault();
$('.focus-me').val('');
}
});
}
if($('.focus-me').length > 0){
setInterval(function(){
$('.focus-me').focus();
},1000);
//if scan field is not focused then hide "scanner ready" message
$(".focus-me").focusout(function(){
$('.focus-in').hide();
$('.focus-out').fadeIn(500);
});
//if scan field is focused then hide "scanner not ready" message
$(".focus-me").focusin(function(){
$('.focus-out').hide();
$('.focus-in').fadeIn(500);
});
//reset the field
$(document).on('keyup',function(e){
if (e.key === ' ' || e.key === 'Spacebar') {
e.preventDefault();
$('.focus-me').val('');
}
});
}
No comments:
Post a Comment