JSFiddle - React, Tailwind, and code Playground
HTML
<form action="http://example.com">
<input type="text" />
<button type="submit">Submit</button>
</form>
<a href="http://google.com">Go to Google</a>
JavaScript
var changes = false;
$('textarea,input').on('keypress change input', function() { changes = true; });
$('form').on('submit', function () { changes = false; });
$(window).on('beforeunload', function () { if (changes) return "Do you really want to leave?"; });