JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://jqueryvalidation.org/files/dist/jquery.validate.min.js"></script>
<form method="POST" id="TestForm">
<input name="txtIn" type="text" id="txtIn"><span class="add"></span>
<p></p>
<button id="submit">Submit</button>
</form>
CSS
label.error:after {
content:"";
display: inline-block;
margin-left:10px;
background: url("http://dummyimage.com/15x15/de1417/de1417.png") no-repeat;
width: 15px;
height: 15px;
}
.validicon {
display: inline-block;
margin-left:10px;
background-color: blue;
width: 15px;
height: 15px;
}
JavaScript
if ($('#TestForm input').hasClass('valid')) {
$('.add').addClass('validicon');
} else {
$('.add').removeClass('validicon');
}
$('#TestForm').validate({
rules: {
txtIn: {
required: true,
rangelength: [8, 16]
}
},
messages: {
txtIn: {
required: "Please enter something",
rangelength: "Icon"
},
}
});