How to prevent text selection on tab key

Discussion in 'ASP .Net' started by bkasmai@gmail.com, Aug 9, 2006.

  1. Guest

    On editing textboxes on a webform, when a user tab to a textbox, the
    text is highlighted or selected. Any accidental key press will remove
    the original text. This has proved a problem for the users. Is it
    possible to set a textbox so that the text is not selected when a user
    tabs to that textbox? Any help on this will be appreciated.
    BK
     
    , Aug 9, 2006
    #1
    1. Advertising

  2. i guess,this works only in IE...

    <script>

    function setCursorPos( x ) {

    var txtRange = x.createTextRange();
    txtRange.moveStart( "character", x.value.length );
    txtRange.moveEnd( "character", 0);
    txtRange.select();
    }

    </script>
    <form>
    <input type="text" >
    <input type=text id="txttest" onfocus="javascript:setCursorPos(this) ;">
    </form>

    Regards,
    Augustin

    "" wrote:

    > On editing textboxes on a webform, when a user tab to a textbox, the
    > text is highlighted or selected. Any accidental key press will remove
    > the original text. This has proved a problem for the users. Is it
    > possible to set a textbox so that the text is not selected when a user
    > tabs to that textbox? Any help on this will be appreciated.
    > BK
    >
    >
     
    =?Utf-8?B?QXVndXN0aW4gUHJhc2FubmE=?=, Aug 9, 2006
    #2
    1. Advertising

  3. Guest

    Hi Augustin

    Many thanks for your reply. It appears that your setCursorPos function
    select text, i.e. highlights the text. I want the opposite. By default,
    my webform select text on tab. I cannot recal changig any default
    behaviour.

    BK
    Augustin Prasanna wrote:
    > i guess,this works only in IE...
    >
    > <script>
    >
    > function setCursorPos( x ) {
    >
    > var txtRange = x.createTextRange();
    > txtRange.moveStart( "character", x.value.length );
    > txtRange.moveEnd( "character", 0);
    > txtRange.select();
    > }
    >
    > </script>
    > <form>
    > <input type="text" >
    > <input type=text id="txttest" onfocus="javascript:setCursorPos(this) ;">
    > </form>
    >
    > Regards,
    > Augustin
    >
    > "" wrote:
    >
    > > On editing textboxes on a webform, when a user tab to a textbox, the
    > > text is highlighted or selected. Any accidental key press will remove
    > > the original text. This has proved a problem for the users. Is it
    > > possible to set a textbox so that the text is not selected when a user
    > > tabs to that textbox? Any help on this will be appreciated.
    > > BK
    > >
    > >
     
    , Aug 9, 2006
    #3
  4. This will not select the text. This will move the cursor to the end of the
    text.

    Regards,
    Augustin

    "" wrote:

    > Hi Augustin
    >
    > Many thanks for your reply. It appears that your setCursorPos function
    > select text, i.e. highlights the text. I want the opposite. By default,
    > my webform select text on tab. I cannot recal changig any default
    > behaviour.
    >
    > BK
    > Augustin Prasanna wrote:
    > > i guess,this works only in IE...
    > >
    > > <script>
    > >
    > > function setCursorPos( x ) {
    > >
    > > var txtRange = x.createTextRange();
    > > txtRange.moveStart( "character", x.value.length );
    > > txtRange.moveEnd( "character", 0);
    > > txtRange.select();
    > > }
    > >
    > > </script>
    > > <form>
    > > <input type="text" >
    > > <input type=text id="txttest" onfocus="javascript:setCursorPos(this) ;">
    > > </form>
    > >
    > > Regards,
    > > Augustin
    > >
    > > "" wrote:
    > >
    > > > On editing textboxes on a webform, when a user tab to a textbox, the
    > > > text is highlighted or selected. Any accidental key press will remove
    > > > the original text. This has proved a problem for the users. Is it
    > > > possible to set a textbox so that the text is not selected when a user
    > > > tabs to that textbox? Any help on this will be appreciated.
    > > > BK
    > > >
    > > >

    >
    >
     
    =?Utf-8?B?QXVndXN0aW4gUHJhc2FubmE=?=, Aug 10, 2006
    #4
  5. Guest

    Thanks Augustin. Regards, BK
    Augustin Prasanna wrote:
    > This will not select the text. This will move the cursor to the end of the
    > text.
    >
    > Regards,
    > Augustin
    >
    > "" wrote:
    >
    > > Hi Augustin
    > >
    > > Many thanks for your reply. It appears that your setCursorPos function
    > > select text, i.e. highlights the text. I want the opposite. By default,
    > > my webform select text on tab. I cannot recal changig any default
    > > behaviour.
    > >
    > > BK
    > > Augustin Prasanna wrote:
    > > > i guess,this works only in IE...
    > > >
    > > > <script>
    > > >
    > > > function setCursorPos( x ) {
    > > >
    > > > var txtRange = x.createTextRange();
    > > > txtRange.moveStart( "character", x.value.length );
    > > > txtRange.moveEnd( "character", 0);
    > > > txtRange.select();
    > > > }
    > > >
    > > > </script>
    > > > <form>
    > > > <input type="text" >
    > > > <input type=text id="txttest" onfocus="javascript:setCursorPos(this) ;">
    > > > </form>
    > > >
    > > > Regards,
    > > > Augustin
    > > >
    > > > "" wrote:
    > > >
    > > > > On editing textboxes on a webform, when a user tab to a textbox, the
    > > > > text is highlighted or selected. Any accidental key press will remove
    > > > > the original text. This has proved a problem for the users. Is it
    > > > > possible to set a textbox so that the text is not selected when a user
    > > > > tabs to that textbox? Any help on this will be appreciated.
    > > > > BK
    > > > >
    > > > >

    > >
    > >
     
    , Aug 10, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hermit Dave
    Replies:
    0
    Views:
    445
    Hermit Dave
    Jan 22, 2004
  2. Otis Mukinfus
    Replies:
    2
    Views:
    617
    Otis Mukinfus
    Jan 14, 2007
  3. M P
    Replies:
    1
    Views:
    492
  4. max
    Replies:
    2
    Views:
    380
    Lambik
    Apr 1, 2007
  5. HopfZ
    Replies:
    0
    Views:
    295
    HopfZ
    Jan 8, 2007
Loading...

Share This Page