Skip to main content
Inspiring
March 30, 2018
Question

Tab = Enter

  • March 30, 2018
  • 2 replies
  • 687 views

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 has been closed for replies.

    2 replies

    WolfShade
    Legend
    March 30, 2018

    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.

    WolfShade
    Legend
    March 30, 2018

    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,

    ^ _ ^

    ctreevesAuthor
    Inspiring
    March 30, 2018

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

    Thank you!

    WolfShade
    Legend
    March 30, 2018

    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,

    ^ _ ^