Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7710337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:06:04+00:00 2026-06-01T01:06:04+00:00

I have a real basic form (code below) with a bunch of back-panel PhP.

  • 0

I have a real basic form (code below) with a bunch of back-panel PhP. There is a scanner being used to input the data, but instead of tab after each item, it sends an “enter” command.

Is it viable to add javascript to cause enter to instead tab to the next form field, and upon the last form field, submit it instead? I have found a few scripts online, but none that I have tried have worked in Firefox/Chrome.

CODE:

<html><head><title>Barcode Generation</title></head><body>
<fieldset style="width: 300px;">
<form action="generator.php" method="post">
Invoice Number:<input type="text" name="invoice" /><br />
Model Number:<input type="text" name="model" /><br />
Serial Number:<input type="text" name="serial" /><br />
<input type="hidden" name="reload" value="true" />
<input type="submit" />
</form><br /><a href=null>en espanol</a></fieldset>
</body></html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:06:06+00:00Added an answer on June 1, 2026 at 1:06 am

    Yes.

    You’ll need to implement an ‘onsubmit’ handler for the form which checks that the [ENTER] key was pressed from the “correct” field (or the form is adequately filled). If not, the handler should just return false (to prevent submission). (Only need to do the next bit.)

    Then you’ll need to implement an ‘onkeypress’ handler for each input that can be scanned, and when you get an [ENTER] key, call .preventDefault() prevent submission of the form, and trigger a [TAB] ‘keypress’ event .focus() the next field.

    Update: this works for me:

    <html>
      <head>
        <title>Barcode Generation</title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript">
    
          function validate() {
            return ((/\S+/.test($('input[name="invoice"]').val())) &&
                    (/\S+/.test($('input[name="model"]').val())) &&
                    (/\S+/.test($('input[name="serial"]').val())));
          }
    
          $().ready(function(){
            $('#generator_form')
              .submit(validate)
              .find('input[type="text"]')
                .keypress(function(evt) {
                  if (evt.which == 13) { // ENTER pressed
                    var next_elem;
                    if (evt.target.name == 'invoice') { next_elem = $('input[name="model"]'); }
                    else if (evt.target.name == 'model') { next_elem = $('input[name="serial"]'); }
                    else if (evt.target.name == 'serial') { return validate(); }
                    $(next_elem).focus();
                    return false;
                  } else { // some other key pressed
                    return true;
                  }
                })
              .end();
          });
        </script>
      </head>
      <body>
        <fieldset style="width: 300px;">
          <form id="generator_form" action="generator.php" method="post">
            Invoice Number:<input type="text" name="invoice" /><br />
            Model Number:<input type="text" name="model" /><br />
            Serial Number:<input type="text" name="serial" /><br />
            <input type="hidden" name="reload" value="true" />
            <input type="submit" />
          </form>
          <br />
          <a href=null>en espanol</a>
        </fieldset>
      </body>
    </html>
    

    Updated: to submit on [ENTER] in ‘serial’ field.

    Updated: to properly validate in all cases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple html form and some php that input the POST variables
I have a line of code in a basic Rails blog application I did
I am inexperienced in WCF so this question may be real basic... I have
I have this real weird exception when issuing a basic SELECT, using MySQL 5.1.32-community
I have a form that takes someone's name. It's a basic regex that only
I have a real basic command-line program, in Objective-C, that searches for user inputed
I have a basic php login script. I have three fields: username, password, and
In this basic jQuery, AJAX, PHP form I want to display errors next to
I have a table like this (basic example, not the real thing): FKEY |
Say I have real, dimension(0:100) :: realResults and I want to iterate over realResults

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.