Focus first field in form when TAB is pressed

  1. #1

    Focus first field in form when TAB is pressed

    Hi,

    I have a form that I want to redirect to first field when TAB is pressed and the last field on the form is focused.
    For this I was trying to use the focus method in the first field, but after it is focused,
    the TAB event redirects the focus to the second field.

    Does anyone know how can I solve this?

    Thanks a lot,
  2. #2
    Hi,

    I guess you have to use preventDefault() method.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:FormPanel runat="server">
            <Items>
                <ext:TextField ID="TextField1" runat="server" FieldLabel="TextField1" />
                <ext:TextField runat="server" FieldLabel="TextField2" />
                <ext:TextField runat="server" FieldLabel="TextField3">
                    <Listeners>
                        <SpecialKey Handler="if (e.getKey() == e.TAB) { e.preventDefault(); TextField1.focus(); }" />
                    </Listeners>
                </ext:TextField>
            </Items>
        </ext:FormPanel>
        </form>
    </body>
    </html>
  3. #3
    Thanks Daniil,

    worked as a charm!

Similar Threads

  1. [CLOSED] Focus first field in RowEditor when shown.
    By pj_martins in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 22, 2011, 3:50 PM
  2. [CLOSED] Default field focus.
    By Jean-Pierre Poulin in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 15, 2010, 11:18 AM
  3. ext:window field loosing focus
    By jmilton in forum 1.x Help
    Replies: 2
    Last Post: Aug 04, 2009, 3:06 PM
  4. Replies: 0
    Last Post: Jun 03, 2009, 3:14 PM
  5. Replies: 1
    Last Post: Apr 15, 2009, 3:35 PM

Tags for this Thread

Posting Permissions