Click here to Skip to main content
14,699,608 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 7:54am
Comments
[no name] 4-Jul-11 3:45am
   
What exactly you want??
   
Do you want to move focus without pressing Tab, just be detecting that all data is filled? Also trivial though...
--SA
   
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.
   
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



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
   
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>
   
v2
Lets Say that you have 4 textboxes, here is the code that will work...

Cheers :)
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
   
hi,

add this one

Textbox1.Focus()



happy coding
   
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