views:

38

answers:

1

if you set "disabled" on a input and submit a form, that field doesn't seem to be in the Request.Form when you post to the server.

What is the logic behind the design decision to not post this field solely based on some presentation layer decision?

This makes no sense to me . ..

+3  A: 

Works as specified by the W3C (albeit a bit cryptical):

Disabled controls cannot be successful. [...]

A successful control is "valid" for submission

If you want to make an element unaccessible for the user, while sending along the value, use the readonly property.

Pekka
Readonly is exactly right, (I know Pekka knows) but ooo if you are not aware do not trust the value of a readonly field because it can be tampered with by the user. I learned this the hard way.
Chris
@Pekka - i understand that i should use "Readonly" but i still dont agree with the design decision to not post disabled controls.
ooo
@ooo it makes sense in my opinion. If you want a value not posted, disable it. If you want it posted but the user unable to change it, make it read only. I've needed both cases when working with forms.
Pekka
@Pekka - the thing is that readonly doesn't change the visualization so i have to add some css to show the user that its not editable (readonly doesn't clearly highlight this)
ooo
@ooo I agree, that *is* a definite shortcoming, especially seeing that the default "disabled" state is almost impossible to simulate using CSS. It's rather the browsers' fault than the specification's though - they are free in rendering it as they wish.
Pekka