A disabled but readable input
Fabián’s Question:
So I have two forms, one is for creating and the other for editing. Both using method="post"
.
There’s one difference between both, which is the code_product
, that is generated via php’s rand()
function, used only when creating a product (so there’s no code_product input here).
And when editing it, the code_product
value is shown inside of an additional input
at the top of the entire form
.
Objective: code_product
‘s input
mustn’t be edited.
Problem: Using the disabled
attribute makes it unreadable for php too.
Avoiding the asp.net (mentioned in another post), is there another way to make it uneditable, through css or javascript?
Add an attribute called readonly
to your input elements. This way it cant be edited but still viewed as normal.
<input type="text" readonly />
For older browsers, you will need
<input type="text" readonly="readonly" />