Showing this is easy, but I feel you need the code to behave accordingly, to prevent characters from entering.
This is a bit less than trivial. You will need to use
onKeyPress
instead.
See:
<html>
<head>
<script type="text/javascript"><!--
function filterOut(eventInstance) {
var character = String.fromCharCode(eventInstance.which);
if (eventInstance.which == 8)
character = "backspace";
alert("You want to enter " + character +
", Guts_ryo? Relax, this text box do not accept any characters!");
eventInstance.preventDefault();
eventInstance.returnValue = false;
return false;
}
--></script>
</head>
<body">
<input type="text" onkeypress="filterOut(event)"/>
</body>
</html>
Pay attention for special processing of backspace. You can use this code to filter out some character sets to get, say, digits only or something like that. Don't forget to allow backspace in all cases.
Sorry, I misread it; though it was "Javascript"! Oops! :-)
—SA