<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2734.1600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>I'm writing a masked edit textbox control for HTML
(client-side script only). I have everything working okay except that I'm
using the onkeyup event to reformat the text. In this case, I allow only
numeric input, but I format it as (nnn) nnn-nnnn for telephone numbers.
The problem comes when I use shift and the left or right arrows to select a
portion of the text, and also when I first tab into the textbox and the entire
text is selected by default. The onkeyup event formats the text properly,
but in the process it deselects the selected text. I can try to circumvent
this by trapping for particular keystrokes, i.e. tab, downshift, etc. and
skipping the formatting. But I would like to know, for the record and for
possible later needs, how to detect the selected text and reselect it after
formatting. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>In VB6 windows controls there are two properties,
SelStart and SelLength, that tell where the selected text begins and how long it
is. Does anyone know of a means of determining the same information
regarding an HTML input of type text? I'm aware of the onselect event, but
I can't find any helpful properties associated with it. Nor do the event
object or its srcElement have anything helpful in this regard.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Does anybody have a
solution?</FONT></DIV></FONT></DIV></BODY></HTML>