Skip to main content
Inspiring
Mar 30, 2018 7:40 PM UTC
Question

Tab = Enter

I have a form that we scan a single number into.  The barcode scanner has an "Enter" built in to it after it scans.

The problem is that these scanners are used for many other programs in our lab that all need a "Tab" and staff have to frequently switch them back and forth between tab and enter.

My form is one simple field and a submit key, so scanning now captures the data and submits it.

Can the form be set to submit when a "Tab" is sent?  So it would be: scan data --> Tab = data submitted.

Thanks

    This topic is closed to new replies. Start a new post to keep the conversation going.

    7 replies

    WolfShade
    Legend
    Mar 30, 2018 8:29 PM UTC

    Okay.. I was close. 

    <form><input type="text" onBlur="this.form.submit();" id="testing" oninput="this.blur();"  /></form>

    HTH,

    ^ _ ^

    UPDATE:  According to caniuse, there are minor issues with using oninput, but it enjoys full support in FF since 3.6, Chrome since 15.0, Safari since 6.1, IE since 10, and Edge since 12.

    Translate
    WolfShade
    Legend
    Mar 30, 2018 9:02 PM UTC

    You can even do it like so:

    <form id="testSubmit"><input type="text" id="testing"  /></form>

    <script type="text/javascript">

        var testSubmit = document.getElementById('testSubmit'),

              testing = document.getElementById('testing');

        function submitIt(){testSubmit.submit();}

        function blurIt(){testing.blur();}

        testing.addEventListener('blur',submitIt);

        testing.addEventListener('input',blurIt);

    </script>

    V/r,

    ^ _ ^

    Translate
    ctreevesAuthor
    Inspiring
    Mar 30, 2018 9:43 PM UTC

    WolfShade, you are awesome, thank you, I will test it next week when I am back to work.

    Thank you!

    Translate
    WolfShade
    Legend
    Mar 30, 2018 8:10 PM UTC

    I think you can use JavaScript to accomplish that.  Set the field so that onBlur="this.form.submit();" and onChange="this.blur();"

    Not tested, but I think theoretically it will work.

    V/r,

    ^ _ ^

    Translate