1

I have put some search and email registration textboxes into a page and I can't click on the field to focus on it and enter text.

After some troubleshooting I discovered that the reason for this, is the main div, that includes the content. It has these rules:

<main id="main" class="site-main" onmousedown="return false;" onselectstart="return false;">

These restrictions were put there for discouraging stealing content. This prevents the user from focusing on the text-fields.

What would be the best way to keep the restriction for the main div, yet allow the user to click on the textboxes? Maybe just the onselectstart is enough to prevent copy/paste and I can delete the onmousedown parameter?

You can see the problem in this page

IXN
  • 173
  • 1
  • 7
  • 1
    Try making a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) instead of linking to that page. Also, why not just try removing the onmousedown parameter? Have you? – vityavv Mar 02 '18 at 01:29
  • Yes, I have and it solves the problem. I just wonder if it offers added benefit in discouraging copy/paste or if 'onselectstart' is enough. – IXN Mar 02 '18 at 01:32
  • 1
    You should post this as an answer and accept it so others can see that your problem was solved, especially if you solved it yourself. – Gerardo BLANCO Mar 02 '18 at 01:35

1 Answers1

0

Since I was not sure why the onmousedown="return false;" was there (I'm a newbie) I decided to leave it there and just add some code around the text-boxes, that would allow the user to click/focus on them.

I found the answer in an older related question. That question had received 24 different answers, but the one that I found the simplest of all and fully understood how to implement, is this:

Use the onclick="this.select()" attribute for the input tag.

This way we keep the restrictions for the main div, but we allow clicking in the input field. Tested and it works.

Community
  • 1
  • 1
IXN
  • 173
  • 1
  • 7