How to prevent text selection on tab key

B

bkasmai

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
 
G

Guest

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
 
B

bkasmai

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
 
G

Guest

This will not select the text. This will move the cursor to the end of the
text.

Regards,
Augustin
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top