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.