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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding characters to input field

Status
Not open for further replies.

rmagan

Programmer
Jun 3, 2003
35
US
I have a form that uses a input text field. When the user enters a value, I need to make it uppercase and add some characters to the begining and end of the field and pass it to a function.

For example: If the users enters "s1" I need to send the value of "/~S1~/" to the function.


<input type=&quot;text&quot; name=&quot;p_chg_semester&quot; Ssize=&quot;5&quot; maxlength=&quot;2&quot; onChange=&quot;IsValidSemester(this.value>);
 
rmagan,

Maybe this will get you started:
Code:
<html><head><title>TEST</title>
<script language=&quot;JavaScript&quot;>
function mkstr(val){
if(val.length == 2) {
out = 'Prefix'+val.toUpperCase()+'Suffix';
document.getElementById('output').value = out;}
}
</script></head><body>
<input type=&quot;text&quot; size=&quot;5&quot; onBlur=&quot;mkstr(this.value)&quot;>
<input type=&quot;text&quot; id='output' size=&quot;20&quot;>
</body></html>

Just shout back if it doesn't do what you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top