I tried:
$(\'input\').keyup(function() {
$(this).attr(\'val\', \'\');
});
but it removes the entered text slightly after a letter is enter
If you want to prevent the user from adding anything, but provide them with the ability to erase characters:
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.
Setting the onkeydown
attribute to return false
makes the input ignore user keypresses on it, thus preventing them from changing or affecting the value.