HighDots Forums  

How to make a html control read only

alt.html.tags alt.html.tags


Discuss How to make a html control read only in the alt.html.tags forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Matt
 
Posts: n/a

Default How to make a html control read only - 03-06-2004 , 03:25 AM






How to make a html control (text box, checkbox, etc...) be read only?
Are there any HTML syntax like that?
For example, in the following text box code, value "Joe" is in text
box, but user still able to edit it. I don't want user able to edit
it.

<input type="TEXT" name="username" value="Joe">

Please advise!

Reply With Quote
  #2  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: How to make a html control read only - 03-06-2004 , 06:16 AM






jrefactors (AT) hotmail (DOT) com (Matt) wrote:

Quote:
How to make a html control (text box, checkbox, etc...) be read only?
Using the attribute readonly (or if you play the XHTML game,
readonly="readonly") in an <input> element. But by the specification,
it applies to elements with type="text" and type="password" only
(though browsers might be more liberal).

Quote:
For example, in the following text box code, value "Joe" is in text
box, but user still able to edit it. I don't want user able to edit
it.

input type="TEXT" name="username" value="Joe"
So why do you have the field there in the first place?

It's safer to use

<input type="hidden" name="username" value="Joe">
Username: Joe

partly because not quite all browsers support the readonly attribute,
partly because this makes it much clearer that the user is not expected
to change the username.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html




Reply With Quote
  #3  
Old   
Ben Measures
 
Posts: n/a

Default Re: How to make a html control read only - 03-06-2004 , 07:59 AM



Jukka K. Korpela wrote:
Quote:
jrefactors (AT) hotmail (DOT) com (Matt) wrote:
input type="TEXT" name="username" value="Joe"

So why do you have the field there in the first place?

It's safer to use

input type="hidden" name="username" value="Joe"
Username: Joe

partly because not quite all browsers support the readonly attribute,
partly because this makes it much clearer that the user is not expected
to change the username.
Huh, never thought of doing that.

Great tip, thanks.

--
Ben M.

----------------
What are Software Patents for?
To protect the small enterprise from bigger companies.

What do Software Patents do?
In its current form, they protect only companies with
big legal departments as they:
a.) Patent everything no matter how general
b.) Sue everybody. Even if the patent can be argued
invalid, small companies can ill-afford the
typical $500k cost of a law-suit (not to mention
years of harassment).

Don't let them take away your right to program
whatever you like. Make a stand on Software Patents
before its too late.

Read about the ongoing battle at http://swpat.ffii.org/
----------------


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.