for(var i = 0; i <= 23; i++){
if (i < 10) {
console.log('0' + i + ' ');
}
else {
console.log(i + ' ');
}
}
<input type="text" id="a" value="aaa">
var inp = document.getElementById('a');
inp.addEventListener('input', function () {
if(inp.value.length <= 3) {
inp.value = 'aaa';
}
});