onkeyDown="ontxtPID(event)
Unless
event
is defined somewhere else, if likely to be undefined at time of event, thus failing before calling the function.
Replace
event
with a value and try again or simply remove it since the event code is probably automatic.
onkeyDown="ontxtPID();"