JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" value="" id="foo" />

JavaScript

function red(obj) {
    obj.style.color = (parseInt(obj.value, 10) < 1) ? 'red' : 'black';
}

document.getElementById('foo').addEventListener('keyup', function () {
    red(this)
})
document.getElementById('foo').addEventListener('mouseup', function () {
    red(this)
})