Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automatic go to next input (Password / Serial key)

    You might know it from several games such as Diablo 2. You have to write down your cd product key in 3 different input boxes, and it varies in length e.g. first box has 4 numbers, second has 3 and last has only 2.

    Then when you’re finished writing down your 9 numbers it will automatic change focus to the submit button.

    You can do that in JavaScript, if you have an activation code or something else on your webpage, and it's quite simple to actually.

    Place this code in your head section on your page:
    Code:
    <script type="text/javascript">
    function toUnicode(elmnt,content)
    {
    if (content.length==elmnt.maxLength)
    	{
    	next=elmnt.tabIndex
    	if (next<document.forms[0].elements.length)
    		{
    		document.forms[0].elements[next].focus()
    		}
    	}
    }
    </script>
    Place this HTML code in your body:
    Code:
    <form name="form" form methode="post" value="active.asp">
    
    <input size="4" tabindex="1" name="first" 
     maxlength="4" onkeyup="toUnicode(this,this.value)">
    
    <input size="3" tabindex="2" name="Second" 
     maxlength="3" onkeyup="toUnicode(this,this.value)">
    
    <input size="2" tabindex="3" name="Third" 
     maxlength="2" onkeyup="toUnicode(this,this.value)"> 
    <br>
    <br> 
    <input type="submit" name="submit" value="submit"
    
    </form>

  • #2
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But how do I ensure that it only goes to another page if they input the right serial code.

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Location
    AZ, USA
    Posts
    685
    Thanks
    6
    Thanked 46 Times in 46 Posts
    This is not a script for serial-code validation, that would require a server-side language and a database usually. This is a script which conveniently switches the focus to the next input box once a specific number of characters has been filled out. It is just a convenience for the user so that he doesn't have to stop typing and move his cursor to the next box.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •