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 8676121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:06:45+00:00 2026-06-12T20:06:45+00:00

I have a javascript code that allows me to jump automatically from a form

  • 0

I have a javascript code that allows me to jump automatically from a form field to the next.

It works using fixed lenght fields.

Example: field TIME can be only 4 numbers, so when the user enters the 4th number, the script focuses on the next field.

It works fine, but I would like to add a feature.

I want to use it in a variable lenght field. My field is composed of LASTNAME (space) First letter of FIRSTNAME.

Example: John Doe will be typed as “Doe J”

The only trick I can think of is to make the field shift when space is pressed + another character is entered. This is the only repeating pattern that would allow the function to be executed with any combination of variable lenght lastnames.

So, any idea how to implement it? I am a beginner in js! Here is the original code:

<SCRIPT TYPE="text/javascript">
<!--
var downStrokeField;
function autojump(fieldName,nextFieldName,fakemaxlength)
{
    var myForm=document.forms[document.forms.length - 1];
    var myField=myForm.elements[fieldName];
    myField.nextField=myForm.elements[nextFieldName];

    if (myField.maxlength == null)
       myField.maxlength=fakemaxlength;

    myField.onkeydown=autojump_keyDown;
    myField.onkeyup=autojump_keyUp;
}

function autojump_keyDown()
{
    this.beforeLength=this.value.length;
    downStrokeField=this;
}

function autojump_keyUp()
{
    if (
           (this == downStrokeField) && 
           (this.value.length > this.beforeLength) && 
           (this.value.length >= this.maxlength)
       )
           this.nextField.focus();
           downStrokeField=null;
}
//-->
</SCRIPT>
  • 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-12T20:06:47+00:00Added an answer on June 12, 2026 at 8:06 pm

    Rather than detecting a space and then a letter, take a look at the string.match() method.

    You can do something like name.match(/^[A-Z][a-z]* [A-Z]$/) on keypress to determine if name contains a capital letter followed by any number of lower-case letters followed by a space and another capital letter.

    However, be aware that you may run into issues with your criteria, such as someone who has a title like ‘Jr’, or last names that have spaces, like “Da Silva” or apostrophes, like “O’Malley”. Accommodating the many special cases in peoples names can be tricky.

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

Sidebar

Related Questions

I have some JavaScript code that works in IE containing the following: myElement.innerText =
I have the following Javascript code that works perfectly: $(document).ready(function() { $(#Select1).setDefault(); $(#Select2).setDefault(); $(#Select3).setDefault();
I have created this simple JavaScript code that allows a user to click on
I have a cgi code that is being called by AJAX from clientside javascript.
I have code that allows a field to be edited via a input thats
I have the following code that works perfectly. It allows the user to 'like'
I have the following simple Javascript code that allows only digits to be entered
I have seen Javascript code that uses parenthesis immediately after a function's closing curly
I have a javascript code that have span tag and inside the span tag
I have some Javascript code that will programmatically register an COM interop assembly by

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.