<input id="word" value="beleive">
<button>Correct</button>
input, button {
  font-size: 100%;
  padding: 5px;
}
var button = document.querySelector('button');
var input = document.querySelector('input');

button.addEventListener('click', function() {
  input.value = autoCorrect(input.value);
});

function autoCorrect(theString) { 
  theString = theString.replace(/cie/gi,"cei"); 
  theString = theString.replace(/([abd-z])ei/gi,"$1ie"); 
  return theString; 
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.