I tried:
$('input').keyup(function() {
$(this).attr('val', '');
});
but it removes the entered text slightly after a letter is entered. Is there anyway to prevent the user from entering text completely without resorting to disabling the text field?
A non-Javascript alternative that can be easily overlooked: can you use the
readonlyattribute instead of thedisabledattribute? It prevents editing the text in the input, but browsers style the input differently (less likely to “grey it out”)e.g.
<input readonly type="text" ...>