Jump to content

Making fields Read Only using CSS


JMosca77

Recommended Posts

Hi,Is there a way to make a field read only using CSS? I need to prevent users from changing field values after a form has been submitted. I think CSS would be the best way to accomplish this without having to create duplicate forms with Read Only fields, but I can't get it to work.Thanks for any help.

Link to comment
Share on other sites

sure do:
elm=document.forms[0];for (i=0;i<elm.length;++ i){  elm[i].disabled=true;}

will that really work? elm is just a form object, is the form object just a collection of the elements in the form?If it does work i did not know that, :)
Link to comment
Share on other sites

will that really work? elm is just a form object, is the form object just a collection of the elements in the form?If it does work i did not know that, :)
Both options worked, however ASPNETGUY's worked better for me because it made all fields (text, radio buttons, etc.) inactive instead of just fields.Thanks guys!
Link to comment
Share on other sites

will that really work? elm is just a form object, is the form object just a collection of the elements in the form?If it does work i did not know that, :)
Yeah it does work, it's just shorthand for the second one.elm.disabled=true;elm.elements.disabled=true;but yeah yours was a bit more detailed so it'd work better cause mine would disable everthing (like the submit button :) )
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...