davedarko / jquery.rfid

jQuery plugin for HID based RFid readers
12 stars 9 forks source link

Enable other textfield #2

Open jakfarza opened 6 years ago

jakfarza commented 6 years ago

i use jquery.rfid, but other textfield disabled or cannot type text, how to solve that problem. first text field for rfid scanner, and other textfield for input text by typing.

davedarko commented 6 years ago

You need something like this in your html inputs that need to be writable.

onfocus="disableReader();"
onblur="enableReader();"

And then this in a JS script tag (replace rfidscan to whatever you've named the object). You could also add these functions via jQuery of course. You need the boolean to prevent any funky double enabling etc.

readerIsActive = true;

function disableReader()
{
    if (readerIsActive) 
    {
        if ($.rfidscan) $.rfidscan('disable');
        readerIsActive = false;
    }
}

function enableReader()
{
    if (!readerIsActive) 
    {
        if ($.rfidscan) $.rfidscan('enable');
        readerIsActive = true;
    }
}