'onload', the script attaches an "onkeyup" event listeners to all the relevant inputs, so that the actions can run unobtrusively . It checks for the key stroke, if it's <enter> , it runs the validation function.
So far so good.
The problem is, I would like to use an alert() to deliver my validation message but if the user hits <enter> to close the alert window.. this too is registered as a keystroke on the field, so of course the alert immediately pops up again; the only way to close the alert window is to use the mouse to click on "close", and that's not very user friendly.
I used this.blur() so as to 'deafen' the event listener temporarily ( or thus was my intent). Of course the problem with that is that when the user closes the window the field is no longer highlighted ( doesn't have focus) and that isn't very user friendly either.
I tried this which just put me back to where I was before, but I will admit it was grasping at straws:
So my question is, is there a way to 'pause' a listener or make it so that it's not active when an alert window is up?