I am trying to build an input validation function that will be called either when the user leaves the text field or when the user hits <enter> inside the tex field. In order to do that, I need to have the function (or two functions) called when 2 types of events are triggered: onblur (for when the text field loses focus) and onkeypress (where I can check if the keycode == 13, and, if it does, to try to validate; if the keycode != 13, I ignore it).
What I am discovering is that when I add the onblur event to the text field, it is only triggered when the text field loses focuses. Similarly, if the keycode is the only event, it gets called on every keystroke. However, if I have both events inside the <input> tag, then the onblur event is triggered BOTH on every keystroke and when the text field loses focus. This means when the user types a keystroke, first the onblur event is triggered then the keystroke event is triggered. (I am using IE6).
Is there any way to include both events but to have them triggered for the appropriate reasons and not to have the onblur event triggered from keystrokes?