Hola
Mari
Creo que sería más sencillo hacerlo de esta forma:
Código PHP:
<html>
<head>
<script type="text/javascript">
function validar(e) {
tecla = (document.all) ? e.keyCode : e.which;
if (tecla==8) return true;
patron =/[A-Za-záéíóúÁÉÍÓÚ]/;
te = String.fromCharCode(tecla);
return patron.test(te);
}
</script>
</head>
<body>
<p><input type="text" onkeypress="return validar(event)" />
</body>
</html>
Saludos,