JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<input type="password" name="user_pass" class="NumCon" id="7">
</form>
JavaScript
function NumCon() {
var result = true;
$(this).closest("form").find('.NumCon').each(function () {
var size = this.value.length;
var NumVal = $(this).attr('id');
if (size <= NumVal) {
$(this).css("background", "#ffc4c4");
result = false;
}else{
$(this).css("background-color", "#ffffec");
}
});
}
$('.NumCon').live('keyup', NumCon());