When working with a JavaScript function I want to prevent characters from being entered into a form if they do not meet certain parameters. The original JavaScript code I used was: 

```js
    function validateLetter() {
        var textInput = document.getElementById("letter").value;
        var replacedInput = textInput.replace(/[^A-Za-z]/g, "");
        if(textInput != replacedInput)
            alert("You can only enter letters into this field.");

        document.getElementById("letter").value = replacedInput;
  }
```

That function worked while I was using only 1 input point in my form, however when I tried to use that function over multiple inputs it would only affect the first one in the form. 

When creating a function that could be reused by multiple input boxes I got the following code:

```js
function validateLetter(dataEntry){
 try {
     var textInput = dataEntry.value;
            var replacedInput = textInput.replace(/[^A-Za-z]/g);
            if (textInput != replacedInput)
                throw "You can only enter letters into this field.";

 }
 catch(InputError) {
  window.alert(InputError)
  return false;
 }
 return true;
}
```

The form I am using to input information is:

```html
<form action="validateTheCharacters" enctype="application/x-www-form-urlencoded">
  <p>Enter your mother's maiden name:
    <input type="text" id="letter" name="letter" onkeypress="validateLetter();" />
  </p>
  <p>Enter the city you were born in:
    <input type="text" id="letter" name="letter" onkeypress="validateLetter();" />
  </p>
  <p>Enter the street you grew up on:
    <input type="text" id="letter" name="letter" onkeypress="validateLetter()">
  </p>
</form>
```

Does anyone know a way to translate the last line of the first function: document.getElementById("letter").value = replacedInput;

To something that can be re-used with the current code.

I tried:
dataEntry.value = replacedInput
But that did not seem to run/change the function at all