<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;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.