Error: TypeError: Cannot read property 'classList' of null code example
Example: Cannot read property 'classList' of undefined
It means that document.getElementById("lastName") is returning undefined and you're trying to call classList on undefined itself.
In your HTML input has the attribute name which equals lastName but there is no actual id="lastname"
Either add the attribute id to your input or change getElementById to getElementsByName.
Note that getElementsByName doesn't return a single item.