Asp.net Enter ile TextBoxlar Arası Geçiş

Asp.net ile hazırlanan bir form içindeki bilgileri kullanıcı doldururken bilgi girişi yapılan textbox’da Enter’a basıldığında diğer textbox’a geçilme işlemini yapacağız ilk olarak kullanıcının bilgi girişi için bir form oluşturuyoruz. Daha sonra script kodlarımızı yazmaya başlıyoruz,
ilk olarak ilk textbox’a focuslama işlemini yapıyoruz
$(‘input:text:first’).focus();
daha sonra klavyeden enter tuşuna basılıp basılmadığını kontrol ediyoruz eğer Enter tuşuna basıldıysa
index numarasını bir arttırıp focusluyoruz..
var key = (e.keyCode ? e.keyCode : e.charCode);
if (key == 13) {
e.preventDefault();
var sonrakitext = $(‘input:text’).index(this) + 1;
$(“:input:text:eq(” + sonrakitext + “)”).focus();
}

textboxentergecis

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>İlk TextBoxa Focus ve diğerlerine Enterla Geçiş www.aspnetornekleri.com </title>
    <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('input:text:first').focus();
            $('input:text').bind('keydown', function (e) {
                var key = (e.keyCode ? e.keyCode : e.charCode);
                if (key == 13) {
                    e.preventDefault();
                    var sonrakitext = $('input:text').index(this) + 1;
                    $(":input:text:eq(" + sonrakitext + ")").focus();
                }
            });
          // www.aspnetornekleri.com
            $('#btntemizle').click(
           function () {
               $('form')[0].reset();
           });
        });
                   
    </script>
</head>
<body><!-- www.aspnetornekleri.com -->
    <form id="form1" runat="server">
    <div align="left">
        <fieldset style="width: 400px; height: 200px;">
            <table cellpadding="3" cellspacing="3" border="0">
                <tr>
                    <td>
                        <asp:Label ID="lblad" Text="Adınız: " runat="server"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txtad" Width="200px" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lbladres" Text="Adresiniz: " runat="server"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txtadres" Width="200px" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lbltel" Text="Telefon Numaranız: " runat="server"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txttel" Width="200px" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblmail" Text="Email: " runat="server"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txtmail" Width="200px" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <!-- www.aspnetornekleri.com -->
                <tr>
                    <td>
                    </td>
                    <td>
                        <asp:Button ID="btnkaydet" Text="Kaydet" runat="server" />
                        <asp:Button ID="btntemizle" Text="Temizle" runat="server" />
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>
    </form>
</body>
</html>

You may also like...

Subscribe
Bildir
guest
0 Yorum
Inline Feedbacks
View all comments
0
Yazı hakkındaki yorum, görüş ve önerilerinizi yazınx
()
x