@marco476
Credo che intendesse sapere SE esiste una determinata chiave, non se il valore della chiave corrispondesse a qualcosa in particolare. Per entrare più nello specifico della domanda:
codice:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Esempio</title>
<script type="text/javascript">
var aArrayEsempio = ["tizio", "caio", "sempronio", "vero", "falso", "ciao", "mondo"];
aArrayEsempio[10] = "valore numero con id = 10";
function checkInput(oToCheckField, oKeyEvent) {
if (!oKeyEvent) { oKeyEvent = window.event; }
var nChar = oKeyEvent.charCode;
if (nChar === 0 || /\d/.test(String.fromCharCode(nChar))) { return true; }
return false;
}
function printValue(oInputField, oOutputField) {
oOutputField.value = oInputField.value && aArrayEsempio.hasOwnProperty(oInputField.value) ? aArrayEsempio[oInputField.value] : "";
}
</script>
</head>
<body>
<form name="myForm">
<table><tr><th>Chiave</th><th>Valore</th></tr>
<tr><td><input type="text" name="chiave" onkeypress="return(checkInput(this, event));" onkeyup="printValue(this, this.form.valore);" onpaste="return(false);" /></td>
<td><input type="text" name="valore" readonly /></td></tr></table>
</form>
</body>
</html>