sc*****@gmail.com wrote:
great replies guys. its good to see that every problem has more than
one solution and everybody is different.
just another quick one, is there a list of keycodes and can somebody
provide a link for it.
You can easily discover that using a simple script:
<input type="text" onkeypress="showKeyCode(event, 'xx');">
<div>keyCode: <span id="xx"></span></div>
<script type="text/javascript">
function showKeyCode(e, id)
{
var e = e || window.event;
var x = e.keyCode || e.which;
document.getElementById('xx').innerHTML = x;
}
</script>
But it was suggested that you don't use keycode because you have a
potentially unknown number of keycodes to deal with. You also want to
deal with some of them differently, so there are at least 3 classes of
code: acceptable, ignore and raise error.
You also don't know if all browsers or user agents have the same
keycodes for all their keys, e.g. Windows 'window' key, Mac OS Apple
key, special function keys, etc.
Using the entered text, you only have to deal with two cases:
1. the value is one of Y, y, N, n or empty string so do nothing,
2. anything else causes an action (error message, etc.)
--
Rob