Dear ljo8877,
Thank you for your answer. Are you certain there is no way to abort the further processing of the event? The reason I prever not to go this route is that by allowing the focus in the next field, I will generate a second blur event - bluring from the next field. This is a problem because my event handler might get triggerred by field #1. The handler detects, for example, an empty field, and refocuses on the field because it should not be empty. However, in the meanwhile the focus changed to field #2 which also has a similar limitation. What you get is a competing refocus between the two fields and an endless loop!
btw - why are you suggesting the slight delay - is that an IE bug?
Sincerely,
Tiran/6footmedia.com
PS - the getElementByID is IE specific - I would probably replace with:
el=document.getElementById
el.focus();
Main Topics
Browse All Topics





by: ljo8877Posted on 2005-03-30 at 21:45:44ID: 13668933
No, it doesn't work as you expect. Instead of counting on the return value you need to call the focus() method, but after a short delay.
).focus();
).focus();
Change your code by adding a function to refocus the field like this:
function refocus(id) {
document.getElementById(id
}
then change your function like this
function myhandler (e) {
var formObj = formProcessor.isMSIE ? window.event.srcElement : e.target;
switch (e.type) {
case "blur":
window.status=="blur: " + formObj.name;
if (formObj.name == "YEARS_IN_BUSINESS") {
window.status="aborting blur"
setTimeout("refocus('" + formObj.id + "')", 0);
return false;
}
break;
}
}
The return value will have no affect.No, it doesn't work as you expect. Instead of counting on the return value you need to call the focus() method, but after a short delay.
Change your code by adding a function to refocus the field like this:
function refocus(id) {
document.getElementById(id
}
then change your function like this
function myhandler (e) {
var formObj = formProcessor.isMSIE ? window.event.srcElement : e.target;
switch (e.type) {
case "blur":
window.status=="blur: " + formObj.name;
if (formObj.name == "YEARS_IN_BUSINESS") {
window.status="aborting blur"
setTimeout("refocus('" + formObj.id + "')", 0);
return false;
}
break;
}
}
The return value will have no affect.