Page 1 of 1
HTML forms - disabled text fields not supposed to pass value
Posted: Thu Oct 30, 2003 11:52 pm
by maniac9
I've noticed something, at least I *think* i have...
I have a form for editing a user profile, and it shows the user their user ID number in a text box that is disabled so they cannot change it. I assumed this value would be passed when the form is submitted, but apparently it is not. Is the only way to get around this to use a hidden field?
Posted: Fri Oct 31, 2003 12:08 am
by scorphus
I haven't noticed it until now! Thanks
Well you will have to do something like this:
Code: Select all
<input type="text" name="email" value="me@myhost.com" disabled="true" /><br />
<input type="hidden" name="email" value="me@myhost.com" /><br />
Cheers,
Scorphus.
Posted: Fri Oct 31, 2003 7:29 am
by maniac9
yeah, that works fine - i guess it makes some sense not to pass a field that is disabled, but it interesting now that this is actually the case, at lease with IE5
Posted: Fri Oct 31, 2003 8:02 am
by scorphus
maniac9 wrote:yeah, that works fine - i guess it makes some sense not to pass a field that is disabled, but it interesting now that this is actually the case, at lease with IE5
I think it makes that sense too. Mozilla also doesn't pass a disabled field, but Opera (6.05) does

! I will test it on more browsers on my Linux box.
Posted: Fri Oct 31, 2003 7:13 pm
by m3rajk
here's a better fix: use the readonly attribute instead
Code: Select all
<input type="text" name="email" value="joe.shmoe@whatever.com" readonly>
try that in your test. tell me if it passes and if it's changable. i think you'll find that unlike the disable which is meant to NOT PASS a value, that this is meant to pass the value one sees
i know from expereince that netscape 7.0, M$IE 5+ and mozilla 1.3.1+ don't pass. i haven't tried on netscape 4.xx but i don't care cuz that wont woork with my site and i make sure ppl know.
fyi: my work around is to set it myself, but then again, on all the instances i use that i know exactly what i want it to be. in the past when i've wanted to block user manipulation i've always used the readonly attribute that has been around since html 3.0
Posted: Fri Oct 31, 2003 11:31 pm
by scorphus
• Opera (6.05) pass the disabled and readonly fileds. There is no how change them.
• M$IE, Mozilla, Firebird, Nautilus, Galeon, Konkeror and Lynx pass only the readonly field. There is no how change the disabled and readonly fields.
• Lynx (2.8.4rel.1) lets you change the readonly filed

!
Cheers,
Scorphus.
Posted: Thu Nov 06, 2003 7:19 pm
by m3rajk
scorphus: then lynx, a gopher browser that very few use, doesn't go to the w3c standard. the standard is that neither one can be changed., that the readonly is passed and disabled is reacted to as if it's not there