473,809 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to prevent text selection on tab key

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 '06 #1
4 2109
i guess,this works only in IE...

<script>

function setCursorPos( x ) {

var txtRange = x.createTextRan ge();
txtRange.moveSt art( "character" , x.value.length );
txtRange.moveEn d( "character" , 0);
txtRange.select ();
}

</script>
<form>
<input type="text" >
<input type=text id="txttest" onfocus="javasc ript:setCursorP os(this) ;">
</form>

Regards,
Augustin

"bk*****@gmail. com" 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 '06 #2
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.createTextRan ge();
txtRange.moveSt art( "character" , x.value.length );
txtRange.moveEn d( "character" , 0);
txtRange.select ();
}

</script>
<form>
<input type="text" >
<input type=text id="txttest" onfocus="javasc ript:setCursorP os(this) ;">
</form>

Regards,
Augustin

"bk*****@gmail. com" 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 '06 #3
This will not select the text. This will move the cursor to the end of the
text.

Regards,
Augustin

"bk*****@gmail. com" 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.createTextRan ge();
txtRange.moveSt art( "character" , x.value.length );
txtRange.moveEn d( "character" , 0);
txtRange.select ();
}

</script>
<form>
<input type="text" >
<input type=text id="txttest" onfocus="javasc ript:setCursorP os(this) ;">
</form>

Regards,
Augustin

"bk*****@gmail. com" 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 '06 #4
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

"bk*****@gmail. com" 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.createTextRan ge();
txtRange.moveSt art( "character" , x.value.length );
txtRange.moveEn d( "character" , 0);
txtRange.select ();
}
>
</script>
<form>
<input type="text" >
<input type=text id="txttest" onfocus="javasc ript:setCursorP os(this) ;">
</form>
>
Regards,
Augustin
>
"bk*****@gmail. com" 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 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2255
by: lkrubner | last post by:
I've got a function, you can see it below, that is being called onmouseup in the textarea on my main form. The idea is to find a selection if possible and store that text in a global variable. I can't get this to work in any browser on a Mac, though it works alright on a PC. What am I missing?
2
3147
by: Danny | last post by:
I have a combo box look up and list items in a table, it is not bound. It works fine but how can I prevent the users from entering in there own data? i have an 'on change' event that when it changes, it does something else to a field based on their selection. I also have the LimitTOList on, but when they click in there, they get an error first that says the 2110-focus cannot move the focus to this control. (I have the .setfocus
0
1116
by: Steve | last post by:
The treeview has this habit of scrolling when you change the tree's selection so that the selected item is visible. 9 times out of 10 this is the behavior that you'd want, but what do I do to prevent the tree view from scrolling when making a selection? Is there a flag I can pass in with the selection change message? Is there a notification that I can grab and block? Thanks
4
2497
by: Adnan Siddiqi | last post by:
Hi Pardon me if I am not making any sense.What I want to know the cordinates of selected text by user so that i can save/retrieve them later.is It possible.I am lookig for both IE and Firefox solution. Thankyou -adnan
2
4299
by: ahynes | last post by:
HI folks, I'm a chem engineer with no VB programming knowledge (as you'll see from my question!) I want a script to open a .txt file, insert pre-defined text into the start and end of the file, then close teh saved file with a .nc extension. I'd like to have this as a batch file or exe file which i can installt o run from my users desktops. I tried doing it in Word using macros and the FileDialog thingy to bring up dialogs for the...
2
19729
by: ahynes | last post by:
HI folks, I need a script to open a .txt file, insert pre-defined text into the start and end of the file, then close teh saved file with a .nc extension. I'd like to have this so I can run it from my desktop. I tried doing it in Word using macros and the FileDialog thingy to bring up dialogs for the user to select his files but it would not save the modified file for me and I couldn;t figure how to get it outside of Word. Code below.
3
2563
by: Dekortage | last post by:
Hi all... I am able to grab the text that a user has selected on a web page, using this code: function moreInfo() { if (!isIE) { var t = window.getSelection(); // act on variable "t";
6
19745
by: Fnord Nase | last post by:
Hi. We're using the dblclick event in some parts of a web app interface, which works okay, but when a user double clicks on a text element, the browser selects some text before executing the event handler. How can I prevent this behaviour? TIA, nase
4
2212
by: since | last post by:
How do I in IE prevent the onclick action from being fired when I am done dragging? have tried "window.event.cancelBubble = true", for onmouseup , onmousedown, and onmousemove handlers. The onclick sort action always seems to get fired. Any help would be greatly appeciated. The following demo is sortable and resizable. I basically don't want the onclick action to be fired if I am resizing a column. Steve <HTML> <HEAD> <style>
6
14951
Frinavale
by: Frinavale | last post by:
I am trying to ask the user for confirmation before a radio button is selected. Currently I'm handling the radio button's onclick event, asking the user to confirm their action and if they hit the 'cancel' button call the preventDefault() method for the event to cancel it. It cancels the event if a selection has already been made for the radio button group (it actually selects it, the reverts it back to it's original value when the...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.