PDA

View Full Version : OnChange event


jolietjake
09-05-2002, 11:24 AM
Hi! Here's my problem.

I have a form with multiple text input tags. When a user changes the tag, then the onchange event run a function to validate this input, and if it isn't correct, then the function clears the input.

But if the user writes the same wrong string in the same input, the onchange envent don't do anything!. Can anyone help me?

PD: need to work on IE5+ and NS6+

RadarBob
09-05-2002, 02:08 PM
I would not clear the input. Let the user see what (s)he typed after you flag the error. That's good user interface design I think. Instead, leave the text there and just hi-light it so the user can see it, then as he types, the old is over-written.

In other words, help the user fix the problem, don't try to fix it for the user with lots of (ultimately unnecessary) code.

Oh, and use good error messages. If your code can tell there's an error, it can tell the user too. For example if there are certain invalid characters:


alert (textbox.text + "is invalid.\n" +
" These characters are not allowed:\n" +
" !, #, /, \")


P.S. BIG Blues Brothers fan here!

adios
09-05-2002, 11:36 PM
Why not use onblur? It's called regardless of whether the property has been altered. Just watch out for endless 'focus/blur' loops (usually involving prompts).