How to prevent text selection on tab key

  • Thread starter Thread starter bkasmai
  • Start date Start date
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
 
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
 
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
 
This will not select the text. This will move the cursor to the end of the
text.

Regards,
Augustin
 
Back
Top