2
I have the following scenario: A input text
which comes with a certain bd value/text but which the user should not be able to edit. To do this, pressing a key in the input
will delete that same pressed character.
What I’m doing is, I use the keydown
in input
, step the event of the key:
<input type="text" value="Texto da base de dados" keydown="apagaLetra(this)" />
Now in function js
is that I’m not quite sure what to do. I can tell which key to press with the e.which
, now erase is I’m not seeing how it’s done.
The end result is: When the user presses a key in the input, from the JS do backspace
It’s like you gave a Backspace input?
– Felipe Avelar
That’s exactly what @Felipeavelar looks like
– CesarMiguel
@Gustavorodrigues, as I confirmed to Felipe Avelar what I want is: Give Backspace when the user inserts a character. Placeholder is no close solution to this. Also because if you want to copy the content of the input, and use the placeholder is absolutely impossible
– CesarMiguel
If the goal is to not let the user edit the input, it would not be easier to simply use the attribute
readonly
?– Kazzkiq
@Kazzkiq, yes I could use the
readonly
. The issue is sometimes clients who demand certain "things" like this :/ But it’s already solved :)– CesarMiguel