JSFiddle - React, Tailwind, and code Playground
HTML
Only valid content: <b>hello</b><br>
<input type="text" class="hello"/>
<button>Dummy</button>
JavaScript
$(function() {
$('.hello').bind('focusout', function(e) {
if(!isValid($(this).val())) {
e.preventDefault();
$(this).focus();
}
});
});
function isValid(str) {
if(str === "hello") {
return true;
} else {
return false;
}
}