Ajax doesn’t call javascript function correctly

php) that via ajax calls a table from another page (temp2.php).
If I execute temp2.php via browser directly it works so the function works. Infact the function validate the input number be assign red or green colour.

temp2.php is here:
https://jsfiddle.net/cg3Lhstz/

if i all temp2.php from temp1.php via ajax, I can see the input field, but when i type inside it doesn’t validate so the function is not correctly executed and in the browser console i have the following error:

temp1.php:1 Uncaught ReferenceError: checkValid is not defined
    at HTMLInputElement.onkeyup (temp1.php:1:1)

temp1.php has the following code:

<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <script src="plugins/jQuery/jquery-2.2.3.min.js"></script>
</head>
<body>
    <div id="trc"></div>
</body>
    
<script>
$("#trkview").show();

  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else { // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (this.readyState==4 && this.status==200) {
      document.getElementById("trc").innerHTML=this.responseText;
    }
  }
  xmlhttp.open("POST","cc_temp2.php");
  xmlhttp.send();

any help ? thanks a lot