Forum: Rails Spinoffs (closed, excessive spam) Returning focus to input element

Dabf458e3222b440598c014e31c2191b?d=identicon&s=25 few1938 (Guest)
on 2008-06-11 17:20
(Received via mailing list)
Using onblur calling code below.  In FF the cursor returns to the
element and immediately moves to the next input element.  In IE the
cursor returns to the element and the onblur immediately fires cause a
loop between dialog window and element.

function chkminlen(obj,nlen) {
  var objid = obj;
  var objval = obj.value;
  var cobj = objval.toString();
  if (objval == '' && nlen > 0) {
    alert("Value for this column is required!\n\nMinimum length is "
+nlen);
    $(objid).activate(); return false;
  }

  if (cobj.length < nlen.toString()) {
    alert("Minimum length for this column is " + nlen);
    $(objid).activate(); return false;
  }
}

I have tried .select() and .select().focus(). have also tried various
uses of the 'return', all cause similar problem.

Frank
969b153010f69ec07458fa1d9e8a413b?d=identicon&s=25 Diodeus (Guest)
on 2008-06-11 21:25
(Received via mailing list)
Why not use onchange instead?
Dabf458e3222b440598c014e31c2191b?d=identicon&s=25 few1938 (Guest)
on 2008-06-12 15:58
(Received via mailing list)
The event is not at fault, the problem is  focus on the input element
is being set to the next input cell and not the one where the event
occurred. The call '$(objid).activate(); return false;' should have
returned focus to the proper element.

I have changed the code somewhat, see
http://www.pastebin.us/?show=m46cb9285
for the latest version of code.

To any others out there, I ask that you take a look and please
responde.

Frank
This topic is locked and can not be replied to.