<script>
window.addEventListener('DOMContentLoaded', function() {
var input = document.querySelector('.test');
input.addEventListener('input', function(e){
this.classList[ this.value?'add':'remove']('green');
});
});
</script>
<style type="text/css">
.green{
border: 5px solid #008000;
}
</style>
<input id="my_input" class="test">