0

I'm wondering if there is a way to allow a form to be selected (clicked) but at the same time make the form unable to have text entered.

I've tried using readonly which gave me the functionality but the cursor it provides is the same as if I set disabled=true and it greys out the input field which is confusing for the user. Is there any alternatives?

1 Answer 1

4
<input class="notype" />

$('.notype').on('keydown', function(e){
    e.preventDefault();
})

What you haven't told us is why. If it's because you want it to be copied to clipboard but not changed, the above won't let you do that, if so please elaborate.

Sign up to request clarification or add additional context in comments.

1 Comment

Great! Thanks, works really well. The reason I want to do it is because I have a date range field and I am using a date picker to select the date. I don't really want users to input dates themselves, because then it gets messy and I have to do a whole bunch of other validation so I want to force them to use the date picker.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.