On text field value changed event using Javascript in SharePoint

I have a text field named as "Code" and in the newform.aspx when the user enter some value I need to call some Javascript function. Below is the code snippet to call a Javascript function on text field value change event.

Code Snippet:
  1.  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script><script type="text/javascript">  
  2. $(document).ready(function() {  
  3. $("input[title='Code']").change(function() {  
  4. alert($("input[title='Code']").val())  
  5. // Call Javascript function  
  6. });  
  7. });</script>