Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to append to a value entered in a text box?

Status
Not open for further replies.

jewilson2

Technical User
Feb 7, 2002
71
US
I have a textbox that is free text on a form. I want to append a '#' sign at the beginning of whatever the user types in this box.

Could this be handled with an onchange event so that it happens as soon as the user clicks outside, or tabs away from this box? Or is there a better way?

Thanks,
Jamie
 
Code:
<input type=text onchange='this.value = "#" + this.value'>

-kaht

banghead.gif
 
Thanks.

Can you have more than one onchange event in a string? I already have an onchange event converting the contents to uppercase, and seem to be having trouble with this append statement.

Code:
<input type=text size=14 maxlength=32 onchange=this.value=this.value.toUpperCase();parent.' + ObjName + '.Item=this.value  onfocus=this.select();parent.' + ObjName + 'Collection.SetCurrentFocus("' + ObjName + 'Item") name=' + ObjName + 'LItem value=' + eval(ObjName + '.Item') + '></input>

I tried:
Code:
onchange=this.value= "#" + this.value.toUpperCase();parent.
but it didn't work
 
nevermind....had the wrong syntax.

this worked like a champ. thanks again.

Code:
onchange=`this.value= "#" + this.value.toUpperCase()`;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top