Input Elements: disabled vs. readOnly

Disabled and readOnly input elements both prevent its data from being changed (at least via the user).
But a disabled input element’s data is not sent with other data when the form is submitted. Could’ve saved me that extra 30-minute debugging time.

 

Comments: 2

Leave a reply »

 
 
 

Lol. Working with it right now. I ran across an article that had some cryptic/technical arguments from someone with the W3C as to why. They were decent, but that’s about it. I understand that they are looking at things from a more wide reaching technical point of view, but they seem to forget the sayings, “You can’t please everyone.” and “What works, and what’s logical are two different beasts.”

“Read-Only”, the coder gets the data easily in one line without a hidden field, but the user gets confused and rightly so.

“Disabled”, the user gets every time and understands with little thought, but the coder gets jack returned if they need it for some reason without extra coding for a hidden field and extra code to check. Holding state data is already a bit bloated, be it via Javascript or PHP.

How it alluded them to state that they look identical and have the only difference aware to only programmer I’ll never understand since surely upwards of 90% of the time that would be the needed and expected action in the “real world”… In both cases the user can’t change the data, so they may as well be the same look to them. The coder needs an option there data-wise in several scenarios, so it makes sense to have them. Then if you wanted it to look like the current “Read-Only” box then that should have been in CSS.

Ex of my opine:
— Normal w/ passed value.
— Greyed nothing passed.
— Greyed w/ passed value.
— Same as above with the box looking different from CSS (like perhaps the way it looks now… 😛 lol.)

Well, that’s my two scents. Haven’t seen a scenario yet that that would have definitely conflicted with.

 

well crap… looks like it yanked my examples since they were html code. sorry bout that.

 

Leave a Reply

 
(will not be published)
 
 
Comment
 
 

 

Resources