473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Moving focus to next field

Hello all,

I have a form and for phone fields i have three text boxes for first
three area code and next three and then last 4. I have the max
characters as 3, 3 and 4 and which works fine but once in the first
phone field after the user enters 3 characters, how can i move the
focus automatically to next phone field and then from second to third.
Any ideas, how i can do this in asp.net? I am using C# as code behind

Dec 6 '05 #1
1 1675
This is client-side, so you have to use ECMAScript (you might call it
JavaScript)...

Here's a sample...

<input id="txtPhone1" maxlength="3"/>
<input id="txtPhone2" maxlength="3"/>
<input id="txtPhone3" maxlength="4"/>

var txtPhone1Obj;
var txtPhone2Obj;
var txtPhone3Obj;
window.onload = function(evt) {
txtPhone1Obj = document.getElementById('txtPhone1');
txtPhone2Obj = document.getElementById('txtPhone2');
txtPhone3Obj = document.getElementById('txtPhone3');

txtPhone1Obj.onkeypress = function(evt) {
if(txtPhone1Obj.value.length == txtPhone1Obj.maxLength) {
txtPhone2Obj.focus( );
}
};

txtPhone2Obj.onkeypress = function(evt) {
if(txtPhone2Obj.value.length == txtPhone2Obj.maxLength) {
txtPhone3Obj.focus( );
}
}
}

This meets all the requirements for being legal for use on the public
Internet: it's standard. More importantly, it's therefore future
proof.

David Betz
http://davidbetz.net/dynamicbliss/
http://davidbetz.net/winfx/

Dec 6 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Nitin | last post by:
Hi I have created function to check date and time. at the time of execution, if date is left empty the function returns the error message but then the focus goes to next field. Next filed is for...
5
by: Martin | last post by:
I have the following function in the onchange event of several text boxes. If the user enters an invalid number the alert displays. I would like to return the user to that same field after he...
1
by: Jens Körte | last post by:
Hi NG! I encountered some strange behaviour when using focus() I use a form with several input-fields. A user can enter stuff. After entering I want to check the value, i.e. that a number is...
12
by: swingingming | last post by:
Hi, in the NorthWind sample database, when clicking on the next navigation button on the new order record with nothing on the subform (order details), we got an order with nothing ordered. How can...
3
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There...
4
by: bienwell | last post by:
Hi, I have a problem and really need your help. In my web page ASPX, I have some text fields to accept data from users. I did form validation like this : <td class="dataTD" style="HEIGHT:...
0
by: jvitti | last post by:
I recently upgraded from Access 2000 to Access 2007 and I am having trouble with moving the focus from 1 form to another. While doing data entry if a similar claim is found the claim view form...
2
dlite922
by: dlite922 | last post by:
Before traversing my code, here's what my goal is and what this function does: I have a table of fields that dynamically grows as the user enters information. A minimum of 3 rows must always...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.