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

Write Protected Form Fields??

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
US
Guys,

I have a form with two fields - a list box and a text box. When you select a part ID from the list box, the part description is automatically entered in the text box ( using a basic JS program). Is there any way that I can protect the text box so that it's contents cannot be changed by the user?? i.e. that after the description appears in the box, he/she can't just overwrite it with something else completely.
 
<input type=&quot;text&quot; onfocus=&quot;this.blur()&quot;> luciddream@subdimension.com
 
luciddream,

Simple yet effective.

Thanks :)
 
you could also try:
Code:
<input type=&quot;text&quot; readonly>
With readonly the text box looks normal, and is part of the tab order, but cannot be changed.
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
although, older browsers dont support it. luciddream@subdimension.com
 
Older browsers don't support CSS or DHTML either. Somewhere along the line you have to decide how much backward compatibility you want your application to have, and how much you want to limit your current functionality and usability in order to achieve this backward compatibility. It's not always an easy call, but it's one programmers have to make all the time (one of the MANY tradeoffs that programmers constantly make).
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
i'm all for tossing out old browsers, in fact i refuse to code for anything before IE5 or Mozilla... but, most people want solutions that will work in NS4, and readonly, doesn't. luciddream@subdimension.com
 
If you're just looking to display information, you should use the <SPAN> tag. Im including only the basics, and this is only gauranteed to work in IE.

<span id=&quot;msg&quot;>Original text</span><br>
<a href=&quot;javascript: changeMsg('New Text')&quot;>Change</a>

<script>
function changeMsg(txt)
{
self.document.all(&quot;msg&quot;).innerHTML = txt;
}
</script>

 
Thanks for all the additional options guys, but I'll stick with luciddream.

:) Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top