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!

disable changing text in text box

Status
Not open for further replies.

karren

Programmer
Feb 26, 2002
42
CA
hello,

i am creating a form where i don't want the user to be able to modify the value that appears in the text box (because this value is automatically created by a calculation script i am using).

i have tried several methods that disable any clicking in the textbox and disable selecting the item, but the user is still able to modify the values of that text box.

does anyone know which code i should use to stop the user from modifying anything in the textarea?

thanks all! :)

karren
 
It's an HTML tag, although you can of course set the property from JS as well :
Code:
<input type="text" readonly="readonly" />
...is an example of a read-only box.
 
In the <input type="text"> add:

onfocus="this.blur(); return true;"

What this does is move the focus away from the text input if someone clicks on it, or if someone tabs to it.

Lee
 
thanks sooooo much everyone!! i need to polish up my javascript skills....you all are great, thanks again!

karren
 
It's like buses - wait all day, and then three turn up at once :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top