View Full Version : how to replace old phone number by new one
elenaenvoy
06-30-2006, 07:54 PM
I have created three textboxes (phone number) and the user can enter 3 digits in first two boxes and 4 digits in the last one. The phone number is prepopulated. User needs to change phone number. When the user manually highlights 3 digits in the first text box and enter 3 new digits, the cursor automatically moved to the second textbox. But I can not enter 3 new digits in the second box without manually highlighting old ones. What code should I use to automatically highlight old digits on cursor move? Can anyone help? thanks!!
felgall
06-30-2006, 10:54 PM
Why have you split the phone number up into three fields like that? Most phone numbers don't fit that format to start with and so would not be able to be entered in the first place.
To automatically highlight the content of a field you use the following Javascript:
formname.fieldname.select();
Melon00
06-30-2006, 11:06 PM
Why have you split the phone number up into three fields like that? Most phone numbers don't fit that format to start with and so would not be able to be entered in the first place.
Pretty sure they are talking about the U.S.
What language do you want it in, and what IDE/compiler are you using?
elenaenvoy
07-03-2006, 09:04 PM
Pretty sure they are talking about the U.S.
What language do you want it in, and what IDE/compiler are you using?
Yes, I'm talking about the U.S. and the code is jsp/xsl. Thanks a lot for any advise.
<tr>
<td bgcolor="#ffffff">
Phone #:
</td>
<td bgcolor="#ffffff" nowrap="true">
<input type="text" class="box" name="Phone1" size="3" maxlength="3" value="{$phone1}" onkeyup="advanceCursor('Phone2',3, this)" ><xsl:if test="$readOnly='true'"><xsl:attribute name="readonly">True</xsl:attribute></xsl:if></input> -
<input type="text" class="box" name="Phone2" size="3" maxlength="3" value="{$phone2}" onkeyup="advanceCursor('Phone3',3, this)" ><xsl:if test="$readOnly='true'"><xsl:attribute name="readonly">True</xsl:attribute></xsl:if></input> -
<input type="text" class="box" name="Phone3" size="4" maxlength="4" value="{$phone3}" ><xsl:if test="$readOnly='true'"><xsl:attribute name="readonly">True</xsl:attribute></xsl:if></input></td>
</tr>
Here is the definition of the function:
function advanceCursor(formElementName, characterCount, currentFormElement){
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.