In your code block:
<script type="text/javascript"> $(document).ready(function(){ function hi(){ alert('hi'); } hi(); }); </script>
hi not a global function. You can access it only within the scope of function(){...} , and not outside.
Since you are using jQuery, you can change the way your function is bound to the onChange event. Instead of calling it from the html tag, you can write:
<script type="text/javascript"> $(document).ready(function(){ function hi(){ alert('hi'); } hi(); $('#cep').on( 'change', function(){ hi(); } ); }); </script>
Legec
source share