focus to change from texbox to texbox


my users are entering SSN number.
To not complicate with a Mask, I simply split SSN number entry into 3 entry textbox fields.

Ideally, when user enters 3 digits into first textbox, then cursor would automatically jump to next textbox where users would ented 2 digits and then would jump to third textbox.

How I can achieve this "cursor jumping" ?

Thank you
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

On the text changed event you can check the length of the string, and if it is the correct length then you can set focus on the next text box

Something like this

if(text1.Text.Length > 2)

on the second one:
if(text2.Text.Length > 1)
Asim NazirCommented:
Instead of > better use == operator. So code will become:

if(text1.Text.Length == 3)

on the second one:
if(text2.Text.Length == 2)
TerraceAuthor Commented:
Thank you for answers.
I was planning to do it that way, however what is the exact command to force focus in the textbox.

Sorry, I forgot to mention in my question that I am using VB.NET and Visual Studio 2003

The text2.focus()  does not work.

Alert/erorr says:   'focus' is not member of 'System.Web.UI.Webcontrols.textbox'

I hope VS2003 has a built in function for focus, otherwise I have to use some java script or similar. (hopefully not)

what should go after text2.   to please VS2003 ?

OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Asim NazirCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TerraceAuthor Commented:

This is supported in .NET Framework 2.0 and above.

Even we plan to upgrade this entire project to 3.5 soon, currently we are in .NETFramework 1.1 still.

Any other suggestions ?

if not built in control, what java script I could use and how ?

Asim NazirCommented:
Try this then:

var txtBox=document.getElementById("ctl00_txtUserName" );
if (txtBox!=null ) txtBox.focus();

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.