Skip to content
Advertisement

javascript enable input on double click

I have a form with some inputs disabled. I want these inputs to be enabled when double clicked. Unfortunately, JS events seem not to fire on disabled inputs.

<input type="text" value="asdf" disabled="disabled" ondblclick="this.disabled=false;">​

Is there a way around this limitation?

Or am I just going to have to wrap any affected input in a span to house the event?

http://jsfiddle.net/vhktx/

Advertisement

Answer

ondblclick does not get fired on a disabled element, you should mark it as readonly:

<input type="text" value="asdf" readonly="true" ondblclick="this.readOnly='';">

http://jsfiddle.net/vhktx/4/

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement