onChange function is not defined

The hi function is only in scope inside the ready event handler. Move it outside of the event handler, or handle the binding inside there (and remove the inline event handler attribute from the markup):

$(document).ready(function(){
    function hi(){
        alert('hi');
    }
    $("#cep").on("change", hi);
});

onchange is only triggered when the control is blurred. Try onkeypress instead.

$("#cep").on("change", function() {
   alert(1);
});

or

<input type="text" name="cep" value="" id="cep" class="required cep field" 
onkeypress="hi()"  />

Use following events instead of onchange:

- onkeyup(event)
- onkeydown(event)
- onkeypress(event)

The hi function is only defined in the ready block. Outside, it doesn't exist anymore.

You don't need to wrap function definitions in .ready(), so just remove it. Alternatively, define the function like this:

window.hi = function() {...}

<script src="http://code.jquery.com/jquery-latest.js"></script>

<script type="text/javascript"> 
function hi(){ 
    alert('hi'); 
} 
</script>

<input type="text" name="cep" value="" id="cep" class="required cep field" onKeyPress="javascript:hi();" />