JSFiddle - React, Tailwind, and code Playground
by j08691
HTML
<form id="contactform">
<input type="text" id="name" placeholder="name" autofocus />
<input placeholder="email" />
<textarea placeholder="message"></textarea>
<input type="submit" />
</form>
CSS
.error {
background:red;
}
JavaScript
$("#contactform").submit(function (e) {
e.preventDefault();
$(":input").not("[type=submit]").removeClass('error').each(function () {
if ($.trim($(this).val()).length == 0) $(this).addClass('error');
});
});