- This topic is empty.
November 22, 2010 at 2:49 pm #30781
I want to prevent a user from typing into an input field. The content is being generated when the user clicks an option. I want want to use disabled=”disabled” and styling it so it looks normal because different browsers are still rendering it differently. I also don’t want to put a div on top to prevent the clicking because that doesn’t seem to semantic. Any other way of doing it? Or am I stuck with the div and some event.stopPropagation?November 22, 2010 at 4:04 pm #72681rickylamerzMember
Found a solution.
November 22, 2010 at 4:36 pm #72661yoboubdirMember
i think the best way, it’s to use disabled=”disabled” property and css.
November 22, 2010 at 5:21 pm #72664January 26, 2011 at 4:19 am #63901ultimatepeMember
Seems to work just as well but requires no jQuery and is much shorter. I haven’t tested it on multiple browser versions though so could fall down on some. I do know that on latest versions of FF it stops the user clicking the input at all, on IE 8 it allows the user to click into the input but the immediately stops them from typing anything.January 26, 2011 at 7:46 am #63899TT_MarkMember
Sorry, I know this question is old, but what on earth is wrong with the ‘readonly’ HTML attribute?January 26, 2011 at 5:59 pm #63806
@ultimatepe, not sure why I didn’t think of that, that sounds like it would work just fine, I’ll test it out eventually. I’m much further in the project and a bit swamped so it’ll have to be at another time.
@TT_Mark, I forget if I tried that, since it was a while ago, if I did try it and didn’t stick with it, it might have been because IE styles a field with a readonly attribute like it does with one with a disabled attribute and the browser default style was overriding mine.
I might be wrong though.