File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Lock Textfields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Lock Textfields" Watch "Lock Textfields" New topic

Lock Textfields

Lauren Pender

Joined: Jun 15, 2001
Posts: 5
How do you lock a textfield so that javascript can change the value in the textfield, but a user cannot?
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Set the textfield to readonly
<INPUT TYPE="text" NAME="filedName" value=whatever readonly>
hope that helps

Lauren Pender

Joined: Jun 15, 2001
Posts: 5
Thanks Dave!
xavier romea
Ranch Hand

Joined: Jun 28, 2001
Posts: 37
The readonly option only works for IE, doesn't it?
I tried on Netscape 4.7 and it doesn't work. I used the onFocus option of the input tag and set: onFocus="this.blur()"
I agree. Here's the link:
subject: Lock Textfields
jQuery in Action, 3rd edition