I have a usercontrol with three textboxes how do i make them autojump when each hits the max length?

I have a usercontrol with three textboxes how do i make them autojump when each hits the max length?I have a usercontrol with three textboxes how do i make them autojump when each hits the max length?
cbruneAsked:
Who is Participating?
 
Obadiah ChristopherConnect With a Mentor Commented:
<asp:TextBox ID="txt1" MaxLength="5" runat="server"></asp:TextBox>
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>

Open in new window

txt1.Attributes.Add("onkeyup", "javascript:autojump(this.id,'" + txt2.ClientID + "');");

Open in new window


<script type="text/javascript" language="javascript">
        function autojump(txt1, txt2) {
            var objtxt1 = document.getElementById(txt1);
            var objtxt2 = document.getElementById(txt2);

            if (objtxt1.value.length == objtxt1.maxLength)
                objtxt2.focus();
        }
</script>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.