JSFiddle - React, Tailwind, and code Playground

HTML

<textarea id='noHTML'></textarea>

JavaScript

var ta = document.getElementById('noHTML');

ta.onkeyup = function (e) {
 var val = this.value;


    // alternate regexp /<[^<>]+>/g    
 if(val.match(/<(\/)*(p|div|span)\s*(.*)>/g)) { // fill the regex with all html tags
  // alert('no html');
  // don't want an alert ? you can replace all html expressions

  // alternate syntax for all entities
  //  this.value = val.replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
  // its long and slow but the choice is yours
  this.value = val.replace(/</g, '&lt;').replace(/>/g, '&gt;');  
 }

}