Disable Input Text Selection

Using JavaScript code you can disable the selection events of HTML web page as well as Input text box. JavaScript code enables you to display the content in a protected way that is not allowed to be selected using mouse events. You can use the following events to stop their action while user is trying to select the content of your HTML web page:

1. onselect

2. onselectstart

3. onmousedown

JavaScript provides a "return" statement that can be used to stop the event action. You can use "return false" to disable these events.

Try the sample below to learn and practice the JavaScript DOM code for developing this functionality:

Edit this code and click update to view output
OUTPUT:
  • HIRE EzineASP.Net Developers