
Untitled
By: a guest on
Apr 24th, 2012 | syntax:
None | size: 1.24 KB | hits: 16 | expires: Never
detect barcode reader input
$("#barcode_form").click(function(){
var focusedElement = "";
$(":focus").each(function(){
focusedElement = $(this).attr("id")
});
if(focusedElement == ""){
$('#text2display').focus()
}
})
if(focusedElement == ""){
//if our focused element is empty
$('#text2display').live('blur', function(){
//when the target loses focus, we invoke blur, the next line focuses again.
//it's also a best practice to do something like fading in the border,
$("#text2display").focus();
});
}
if(focusedElement == ""){
//if our focused element is empty
$('#text2display').live('blur', function(){
//when the target loses focus, we invoke blur, the next line focuses again.
//it's also a best practice to do something like fading in the border,
$("#text2display").focus(function(){
$(this).animate({
//when the element has been re-focused, we'll give it a red border briefly.
borderColor: '#ff0000';
}, function(){
//once the animation completes, fade the border out
$(this).animate({ borderColor: 'transparent' }, 2000);
}
);
});
});
}
input{
border:1px solid transparent;
}