Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
1.92/5 (5 votes)
See more:
PLEASE ANYBODY GUIDE ME
Focus to next textbox when previous textbox is filled by an data wheather the data is string or numeric.
Thanks in Advance!
Posted
Updated 4-Aug-20 6:54am
Comments
[no name] 4-Jul-11 3:45am    
What exactly you want??
Sergey Alexandrovich Kryukov 4-Jul-11 3:48am    
Do you want to move focus without pressing Tab, just be detecting that all data is filled? Also trivial though...
--SA
Sergey Alexandrovich Kryukov 4-Jul-11 3:48am    
Also, tag it: WPF, Forms, ASP.NET, what?
--SA

Set the tabindex's appropriately.
As a result, the user should just be able to press tab and control should focus to the next textbox.
 
Share this answer
 
Comments
Jeeva Venkatesh 4-Jul-11 3:52am    
very thanks sir but i want to focus when user enter their data into an textbox at that time the textbox length will be fulfilled by an data. Now automatically focus to the textbox without pressing tab or some other keys like enter
hi,

so simple

i am adding windows form c# code u can easly change to vb just look this



C#
private void textBox1_TextChanged(object sender, EventArgs e)
{
    int s = textBox1.Text.Length;
    if (s==6)
    {
        textBox2.Focus();
    }
}



where once txtbx1 has 6 charecter it automatically focus to txtbx 2


happy coding
any doubt ask me
 
Share this answer
 
Call this from page load:
txtFirst.AddTextBoxAttribute("onkeyup", "javascript: TextBoxFocus()");
txtFirst.AddTextBoxAttribute("onblur", "javascript: TextBoxFocus()");


And write this script,
<script type="text/javascript">
  function TextBoxFocus() {
            var length = $("[id$=_txtFirst_txt]").val().length;
            if (length == 8) {
                $("[id$=_txtSecond_txt]").focus();
            }           
        }
</script>
 
Share this answer
 
v2
Lets Say that you have 4 textboxes, here is the code that will work...

Cheers :)
VB
Private Sub TextBox2_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox2.TextChanged, TextBox3.TextChanged, TextBox4.TextChanged, TextBox5.TextChanged

        Dim txtbox As Control = DirectCast(sender, TextBox)

        If txtbox.Text.Length = 4 Then
            Me.GetNextControl(ActiveControl, True).Focus()

        End If
    End Sub
 
Share this answer
 
hi,

add this one

Textbox1.Focus()



happy coding
 
Share this answer
 
Comments
Jeeva Venkatesh 4-Jul-11 3:53am    
very thanks sir but i want to focus when user enter their data into an textbox at that time the textbox length will be fulfilled by an data. Now automatically focus to the textbox without pressing tab or some other keys like enter
anvas kuttan 4-Jul-11 4:02am    
hai see ma post

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900