ReadOnly Input Fields in Javascript

To do a read only input fields I normally do a:

However some older web browsers do not support this entirely. In my case I was losing the attibute tags across post back in asp.net. Anyway, I came across a different way of doing this using Javascript. I have no idea why I hadn’t thought of this earlier, it kinda makes me feel dumb ;)

I know that some people will frown on this because Javascript must be turned on. But in my case, Javascript is required to be turned on to run the application because of the AJAX stuff I am doing.

NOTE:Someone at work pointed out another way that you can do this that I never used before, by using the “disabled” attribute.

I think this is a case where you do something one way for so long (like I did the readyonly attribute) and you can miss out on other ways that have their individual advantages.

Tim

A .NET, PHP, Marketing Guru authority, at least I hope I am. Reach me at tboland@gmail.com

3 thoughts on “ReadOnly Input Fields in Javascript

  1. nerd says:

    NEEEEEEEEEEEEEEEERDDD

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>