Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to prevent text selection on tab key

Reply
Thread Tools

How to prevent text selection on tab key

 
 
bkasmai@gmail.com
Guest
Posts: n/a
 
      08-09-2006
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QXVndXN0aW4gUHJhc2FubmE=?=
Guest
Posts: n/a
 
      08-09-2006
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

"(E-Mail Removed)" 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
>
>

 
Reply With Quote
 
 
 
 
bkasmai@gmail.com
Guest
Posts: n/a
 
      08-09-2006
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
>
> "(E-Mail Removed)" 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
> >
> >


 
Reply With Quote
 
=?Utf-8?B?QXVndXN0aW4gUHJhc2FubmE=?=
Guest
Posts: n/a
 
      08-10-2006
This will not select the text. This will move the cursor to the end of the
text.

Regards,
Augustin

"(E-Mail Removed)" 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
> >
> > "(E-Mail Removed)" 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
> > >
> > >

>
>

 
Reply With Quote
 
bkasmai@gmail.com
Guest
Posts: n/a
 
      08-10-2006
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
>
> "(E-Mail Removed)" 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
> > >
> > > "(E-Mail Removed)" 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
> > > >
> > > >

> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to make send key ([tab] [tab]Text [Enter]) in some program (Internet Explorer or Notepad)? max Perl Misc 2 04-01-2007 10:12 AM
How can I capture tab key event and cancel default action of Tab key? HopfZ Javascript 0 01-08-2007 10:04 PM
Replace Tab Key to Return Key (Enter Key) from Web Forms? M P ASP General 1 08-06-2004 08:32 AM
Re: URgent!!!!!!!!!!!! change tab selection Tab strip control Hermit Dave ASP .Net 0 01-22-2004 11:02 PM



Advertisments