JSFiddle - React, Tailwind, and code Playground
by Brett Gaynor
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<form action="/action_page.php">
Alt <input type="text" name="e1_alt" required>
<input type="submit">
<div class="error" style="display: none"><i class="fa fa-exclamation-triangle"></i> You need to fill this out.</div>
</form>
JavaScript
$('[name="e1_alt"]').blur(function(e) {
var value = $(e.currentTarget).val();
if (value.length === 0) {
$('.error').show();
}
});