How can I prevent any user from opening disabled input in the browser? Is there an easy way to do this or what should I do?
I use Vuejs in my project
I need to do this as a security measure
I couldn’t find a solution
How can I prevent any user from opening disabled input in the browser? Is there an easy way to do this or what should I do?
I use Vuejs in my project
I need to do this as a security measure
I couldn’t find a solution
2
Answers
If you mean that the user cannot type on the input field, there are many ways and strategies you can do it and this can be tricky. Some of which that I can think of are as follows.
<div>
styled to make it look like an<input>
and the real<input>
is ondisplay: none;
and display it whenever you want the<input>
to be accessed.click
event and theblur()
function:Code for option 2:
The
onfocus
attribute of<input>
fires when the user is about to type to the field while theblur()
function removes the focus.If you mean that you don’t want users to open devtool and inspect your input tag and remove
disable
property, it is impossible.But security concerns can be satified by other methods such as validating it from submit event or through backend APIs.
Therefore you should approach it in other way.