If you want to prevent the user from adding anything, but provide them with the ability to erase characters:
<input value="CAN'T ADD TO THIS" maxlength="0" />
_x000D_
Setting the maxlength
attribute of an input to "0"
makes it so that the user is unable to add content, but still erase content as they wish.
<input value="THIS IS READONLY" onkeydown="return false" />
_x000D_
Setting the onkeydown
attribute to return false
makes the input ignore user keypresses on it, thus preventing them from changing or affecting the value.