JSFiddle - React, Tailwind, and code Playground

HTML

<form action="salva.php" method="post">
 Your Name: <input type="text" name="name" required />
<input type="submit" name="name" />
</form>

CSS

input:required:invalid, input:focus:invalid { background-image: url(http://www.the-art-of-web.com/images/invalid.png); background-position: right; background-repeat: no-repeat; } 
input:required:valid { background-image: url(http://www.the-art-of-web.com/images/valid.png); background-position: right; background-repeat: no-repeat; }