473,556 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

disabled vs readonly input elements


Hi all,

I have form elements that I want to not be editable. They should,
however, be passed on submission. AFAIK, then, they need to be readonly.
(intranet app where elments are created server-side according to perms
of user with a jsp taglib, so users get some elements they can edit and
some they can't, but all will be passed to next page)
The problem with the readonly elements is, when I highlight the text, it
highlights as though it is editable. When I then click backspace, as if
to delete it, it goes back in the browser history (NN7 and IE6).
I want the behavior to be that a user cannot even focus the element if
it is readonly (like it would be if it were disabled). I also want
readonly elements to be greyed out like they are when they are disabled.
Can this be done without using style or javascript? (I can do both with
style and JS, just wondering if there was a pure html way without using
hidden fields.)

TIA
--
--
~kaeli~
In democracy your vote counts. In feudalism your count votes.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #1
4 22370
On Tue, 6 Jan 2004 14:40:59 -0600, kaeli declared in
comp.infosystem s.www.authoring.html:
I want the behavior to be that a user cannot even focus the element if
it is readonly (like it would be if it were disabled). I also want
readonly elements to be greyed out like they are when they are disabled.
Can this be done without using style or javascript? (I can do both with
style and JS, just wondering if there was a pure html way without using
hidden fields.)


No. You can make it grey with CSS, but you can't stop the user from
highlighting it. You could try and stop them from highlighting it using
Javascript, but it won't work for everyone, and may annoy others. Does
it actually need to be in an input field? Why not put it as normal text,
and include it as a hidden field if you need it to be submitted?

--
Mark Parnell
http://www.clarkecomputers.com.au
Jul 20 '05 #2
Mark Parnell wrote:
No. You can make it grey with CSS, but you can't stop the user from
highlighting it. You could try and stop them from highlighting it using
Javascript, but it won't work for everyone, and may annoy others. Does
it actually need to be in an input field? Why not put it as normal text,
and include it as a hidden field if you need it to be submitted?


::selection and/or ::-moz-selection

<http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#UIfragments>
<http://bugzilla.mozill a.org/show_bug.cgi?id =176170>
--
Anne van Kesteren
<http://www.annevankest eren.nl/>
Jul 20 '05 #3
In article <2i************ *************** *@40tude.net>,
we*******@clark ecomputers.com. au enlightened us with...

No. You can make it grey with CSS, but you can't stop the user from
highlighting it. You could try and stop them from highlighting it using
Javascript, but it won't work for everyone, and may annoy others. Does
it actually need to be in an input field? Why not put it as normal text,
and include it as a hidden field if you need it to be submitted?


Okay.

Looks like it's javascript/CSS.
This is an intranet app (with about 100 users) where everyone uses the
same stuff (IE6/NN7), so no worries over it not working for some.
Javascript and CSS are required. The site intentionally doesn't work if
they are turned off. This is something I'd *never* do on an internet
site, so don't yell at me. :)
It used to be text if it wasn't editable, but people didn't like that
look. They wanted a more consistent look and feel.

--
--
~kaeli~
Going to church doesn't make you a Christian any more than
standing in a garage makes you a car.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #4
"kaeli" <ti******@NOSPA M.comcast.net> schrieb im Newsbeitrag
news:MP******** *************** *@nntp.lucent.c om...
In article <2i************ *************** *@40tude.net>,
we*******@clark ecomputers.com. au enlightened us with...

No. You can make it grey with CSS, but you can't stop the user from
highlighting it. You could try and stop them from highlighting it using
Javascript, but it won't work for everyone, and may annoy others. Does
it actually need to be in an input field? Why not put it as normal text,
and include it as a hidden field if you need it to be submitted?


Okay.

Looks like it's javascript/CSS.
This is an intranet app (with about 100 users) where everyone uses the
same stuff (IE6/NN7), so no worries over it not working for some.
Javascript and CSS are required. The site intentionally doesn't work if
they are turned off. This is something I'd *never* do on an internet
site, so don't yell at me. :)
It used to be text if it wasn't editable, but people didn't like that
look. They wanted a more consistent look and feel.


I totally agree with you that from a usability point of view the actual spec
regarding disabled and read only elements is a mistake. In many applications
it is necessary to display form fields with values that cannot be changed,
but have to be visible for consistence and must be submitted, too. I don't
really see a reason for the behaviour which is actually described in the
specs and realized in the browsers.
- The read-only fields with the behaviour that you describe, but not greyed
out or otherwise visibly marked are a kind of confusing the user.
- The fact that disabled fields are not submitted is not satisfactory. There
might be cases where the value is not needed, but then we could just not
process it at the server side. For the other cases, where the value _is_
needed, there is no possibility in HTML.

What you can do is:
- use a disabled field
- add a hidden field with the same value
- when processing the form check for the disalbled field; if it is not
submitted take the hidden one.

I filed that problem to the W3C list in december:

http://lists.w3.org/Archives/Public/...3Dec/0116.html

and got an interesting answer from Jukka K. Korpela:

http://lists.w3.org/Archives/Public/...3Dec/0117.html

HTH
Markus
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1970
by: Matt | last post by:
what's the differences between readonly and disabled attribute?? When I do the post, it couldn't get both values <%= fname %>. any ideas?? <input type="text" name="fname" value="Joe" readOnly> <input type="text" name="fname" value="Joe" disabled>
1
6203
by: David Wake | last post by:
I have two radio buttons and two checkboxes in a form. I'm trying to write some code so that when a radio button is selected, its corresponding checkbox is disabled. My code looks like this: function radioClicked(index) { document.table_config_form.my_checkbox.disabled = true;
2
7567
by: lehmann | last post by:
Hello, Is it possible to have a disabled input in a form whose value could be sent when the form is submitted. I just need the user not to be able to change the input value, but this value is significant and must be sent thanks for any help, G.
1
11619
by: Ittay Dror | last post by:
Hi, I have a form with various elements which, according to changes in values become enabled or disabled. The disabled elements are normally not submitted, but I wish they were. How can I go about making elements appear to be disabled, but still send them when the form is submitted. Thanx,
2
1508
by: Saravanan K | last post by:
Hi, I am having a problem with right click option with Netscape 4.7. I am unable to make the Text field read-only using the Onfocus = "this.blur()" but user is able to use the right click option which will open the edit menu (popup menu) and he is able to cut, copy paste options. Please send me solution for this.
3
1320
by: Gautam | last post by:
hi group i am developing an application , we have to run it for Netscape V4.76(!!) , the problem is it seems that Netscape V4.76 does not support 'disabled' for form elements for example something like <INPUT class=f2 type=checkbox value="C" name="chkAttr" DISABLED /> is not working for netscape whereas its working fine for IE
2
4425
by: upersson | last post by:
Hi! When accessing my web page I build up the javascript and html dynamically. Depending on an parameter I want to set all the fields (input tags) readonly. How do I do this? Of course I can write if statements to add different input tags with and without the readonly attribute. But is it possible to write a javascript that onload search...
1
2665
by: Morten Plathe | last post by:
Hi, Is there a way to override the shadowed (grey) backcolor of a textbox when the textbox is disabled for input (textbox.enabled = false) ? In some cases I want to have a custom backcolor when the textbox is disabled. The same question applies for a listview. When the listview is disabled, the backcolor of the listview turns grey...
2
5652
by: pbd22 | last post by:
Hi. Is this possible? In my program, I have GMap logic that outputs location information to a disabled input field (was previously a label). Then, when a user clicks on a link (to start a new map), I want to save the location data to an array prior to server processing. So, onchange, save the input field's value to array. But, because...
0
7624
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7828
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7907
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6178
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5171
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3576
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1161
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.