a/20885113/1636522

HTML

<input type="text" id='msginput' placeholder="Write your message..." spellcheck="false"/>

JavaScript

var input = document.getElementById('msginput'),
		output = document.getElementById('msginput'),
		badwords = /\b(ugly|evil|bad)\b/g;

	input.onkeyup = function () {
  console.log(this.value);
		output.innerHTML = this.value.replace(badwords, function (fullmatch, badword) {
			return '<sub>' + new Array(badword.length + 1).join('*') + '</sub>';
		});
	};

	input.onkeyup();