JSFiddle - React, Tailwind, and code Playground

HTML

<form>
    <input type="text" value="some < nasty > html" />
</form>

<form>
    <input type="text" value="some < nasty > html" />
</form>

JavaScript

$('form :input').val(function() {
   return this.value
      .replace(/&/g, "&amp;")
      .replace(/</g, "&lt;")
      .replace(/>/g, "&gt;")
      .replace(/"/g, "&quot;")
      .replace(/'/g, "&#039;");
});