<input id="test">
<script>
window.onload = function () {
var test = document.getElementById('test');
test.onkeyup = function () {
var value = test.value;
if (value.length == 1) {
var num = value[0];
if (num == 7) {
alert(num);
} else if (num == 3) {
alert(num);
}
}
}
}
</script>