473,387 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2093
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

"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.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

"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.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

"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.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
>
"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
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...
2
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...
0
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...
4
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...
2
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...
2
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...
3
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
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...
4
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...
6
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.