You have the following:
document.getElementById("zipmessage")
But you don't have such an element. If you add that element, it works.
function checkzip() {
var zip = document.getElementById("zipcode").value;
var regex = /^[0-9]{5}$/;
if (regex.test(zip)) {
document.getElementById("zipmessage").innerHTML = "Valid";
} else {
document.getElementById("zipmessage").innerHTML = "Please enter a 5 digit numeric zip code";
}
}
<table>
<tr>
<td>Zip Code:</td>
<td>
<input id="zipcode" name="zipcode" type="text" onclick="this.focus()" onblur="checkzip();" required/>
</td>
</tr>
</table>
<div id="zipmessage"></div>
But, as you have said that you are learning this from an "instructor", let me tell you that you are not learning using modern, best-practices and some of what you are doing should be avoided.
So, here's the more correct way to do this:
// Just get a reference to the element, not a particular
// property of an element. That way, if you want to access
// a second property, you won't have to scan for the element
// reference a second time.
// Also, get references that you'll need over and over outside of your
// function so you don't keep getting the same reference over and over
// Do you event binding in JavaScript, not HTML:
var zip = document.getElementById("zipcode");
zip.addEventListener("blur", checkzip);
var message = document.getElementById("zipmessage");
function checkzip() {
// Having this.focus() in an event handler that runs when you click
// on an element is redundant. If you've clicked the element, it
// will get the focus.
var regex = /^[0-9]{5}$/;
if (regex.test(zip.value)) {
message.textContent = "Valid";
} else {
message.textContent = "Please enter a 5 digit numeric zip code";
}
}
<table>
<tr>
<td>Zip Code:</td>
<td>
<!-- Don't use self-terminating syntax.
Also type="text" is not necessary since text is the
default type of input. -->
<input id="zipcode" name="zipcode" required>
</td>
</tr>
</table>
<div id="zipmessage"></div>
Unfortunately, there are so many tutorials, lessons, and teachers that don't really know HTML and JavaScript properly and show how to get code to "work". Working code is not always "correct" code or "good" code. You should inform your instructor of the incorrect things they are teaching that I've shown here.