Is css the best way to make a form editable versus non-editable based on permissions?

I have a form.  Based on permissions, it will either be
- readonly;
- partially editable (some fields will remain uneditable);
- fully editable (all fields will be editable)

Is css *the* way to do this, or are there more technical, programmatic ways to do this?  I am inclined to use css but want to make sure that there might not be another way.

Please provide a pseudo-code sample when replying if possible ...

Who is Participating?
I don't think that read-only is cross browser, but ie only.
disabled is compatible with all browsers.
But you must be aware that a disabled field will not be posted with the form.
So, if you need to get back their values, you would have to use input hidden with the same name containing the same value.
CSS will enable you to hide/show some of your fields.
If this is what you need, then it is definitely the best way to do this. Use class names to hide of show with display or visibility attributes.
If you do not want to hide them but just disabling them, you will have to add an attribute to the field you do not want to be edited (disabled="true"), either directly in the tag:

<input type="text" disabled="true"/>

or with Javascript:

document.forms["nameOfMyForm"].elements["nameOfFieldToBeDisabled"].disabled = true;
pingdeeAuthor Commented:
This leads me to better clarity - indeed, I do not want to hide fields but simply make them read-only or disabled.  Is disabled the best bet, or is read-only?  
pingdeeAuthor Commented:
thanks, smaccari - i think that i got all i need :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.