You have the algorithm right there basically, all you need to do is package it.
Just write a function to get the value of the text field, then compare it to the current variable - if they are the same, continue - if not give an alert message or something.
I guess onChange in the text field yu want to set a variable which indicates the person has started typing - since you don't want them to be penalised for being slow to find the right number (or do you?).
Then set the timeout to check this variable after 5 seconds and alert them if they have not complied. -BB "Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer"