Where you loop through your objects in looking for the textbox, you could possibly look for
(el.id == "txtTicketNo"))
instead of
(el.name == "txtTicketNo"))
I'm also not convinced of looking for a type of "textbox". For some reason that looks wrong to me, but it may just be the type of day I'm having.