mharper
02-27-2012, 07:19 PM
Hi,
I'm having some problems with some javascript events firing in the wrong order under certain workflows. Here's the gist of it:
I have a form with many fields, mostly input type = text. Each field as an OnBlur and OnFocus event tied to javascript functions.
IE's website (http://msdn.microsoft.com/en-us/library/ms536909%28v=vs.85%29.aspx) states that "The onblur event fires on the original object before the onfocus or onclick event fires on the object that is receiving focus." and that is exactly what happens when tabbing through the fields.
The tricky part is that it doesn't perform this way when CLICKING to another field. When clicking to another field it performs the new field's OnFocus first, and then the first field's OnBlur event after. This is bad because the OnFocus sets a global variable's value to whatever value is in that box at the time it gets focus and if the onblur validation fails, that value is inserted back into the box. So what's happening is the validation for field 1 fails and the value from field 2 is then written into field 1.
This also seems to only happen when the page is opened as a modal window as opposed to just opening the page on it's own. It doesn't happen in FireFox, I've only been able to get it to happen on IE 8 + (haven't tried any other browsers.)
Anyone else have this happen to them? Does it sound like an IE bug?
Thanks
I'm having some problems with some javascript events firing in the wrong order under certain workflows. Here's the gist of it:
I have a form with many fields, mostly input type = text. Each field as an OnBlur and OnFocus event tied to javascript functions.
IE's website (http://msdn.microsoft.com/en-us/library/ms536909%28v=vs.85%29.aspx) states that "The onblur event fires on the original object before the onfocus or onclick event fires on the object that is receiving focus." and that is exactly what happens when tabbing through the fields.
The tricky part is that it doesn't perform this way when CLICKING to another field. When clicking to another field it performs the new field's OnFocus first, and then the first field's OnBlur event after. This is bad because the OnFocus sets a global variable's value to whatever value is in that box at the time it gets focus and if the onblur validation fails, that value is inserted back into the box. So what's happening is the validation for field 1 fails and the value from field 2 is then written into field 1.
This also seems to only happen when the page is opened as a modal window as opposed to just opening the page on it's own. It doesn't happen in FireFox, I've only been able to get it to happen on IE 8 + (haven't tried any other browsers.)
Anyone else have this happen to them? Does it sound like an IE bug?
Thanks