Categories
HTML

How to prevent user from typing in text field without disabling the field with HTML?

Spread the love

Sometimes, we want to prevent user from typing in text field without disabling the field with HTML.

In this article, we’ll look at how to prevent user from typing in text field without disabling the field with HTML.

How to prevent user from typing in text field without disabling the field with HTML?

To prevent user from typing in text field without disabling the field with HTML, we can add the readonly attribute to the input.

For instance, we write

<input readonly type="text" />

to stop users from enter text into the input without making it look disabled.

Conclusion

To prevent user from typing in text field without disabling the field with HTML, we can add the readonly attribute to the input.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.