This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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 Head First Android this week in the Android 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()"
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Lock Textfields
jQuery in Action, 3rd edition