I have a disabled text field that I want to become enabled when I click it. Unfortunately, it seems that the text field’s click() event doesn’t fire while it’s disabled.
Is there a way around this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately, disabling a control also disables its events (it’s by design).
To work around that limitation, you could add a
<div>absolutely positioned above the<input>field (higherz-index) and attach theclick()event to that<div>. Once clicked, dispose of the<div>and enable your<input>.If you just want to prevent the user from changing the value of the
<input>, usereadonlyinstead ofdisabled. This will not disable the event handlers.