× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You're JavaScript is missing some an ending bracket "}" and a semi-colon
";".

Here is the source that worked for me. You will have to change the onkeyup
to onkeyup(event, this, 'ssn1');. That just gives it a little better cross
browser support.


function autotab(e, original, destination) {
var evtObj = window.event ? event : e;
var code = evtObj.which ? evtObj.which : evtObj.keyCode;
if (code == 9 || //tab
code == 16 || //backtab
code >= 37 && code <= 40 || //arrow keys
code == 45 || //insert
code == 46 || //delete
evtObj.shiftKey) //shift
{
return false;
} // no autotab on tab/backtab/insert/delete/shift

if(original.getAttribute &&
(original.value.length==original.getAttribute("maxlength"))) {
elem = document.getElementById(destination);
elem.focus();
}
}

--
James R. Perkins


On Mon, Apr 27, 2009 at 12:42, Nick Arndt <nick.arndt@xxxxxxxxx> wrote:

Hi all I am having some trouble getting this to work.


I am getting an error Elem is null or not an object.

here is my java script:

function autotab(original,destination)
{

if (document.all) // if IE
{

if (event.keyCode == 9 || //tab
event.keyCode == 16 || //backtab
event.keyCode >= 37 && event.keyCode <= 40 || //arrow keys
event.keyCode == 45 || //insert
event.keyCode == 46 || //delete
event.shiftKey) //shift
{ return } // no autotab on tab/backtab/insert/delete/shift
}


if

(original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
elem = document.getElementById(destination);
elem.focus()
}
</SCRIPT>


and here is my jsf code that is invoking the function:


<h:inputText
styleClass="inputText" id="ssn1"
size="3"
onkeyup="autotab(this, 'ssn2');"
maxlength="3">
<f:validateLength
maximum="3"></f:validateLength>
<hx:validateConstraint regex="^[0-9]+$"
/>
</h:inputText>-

<h:inputText styleClass="inputText" id="ssn2"
size="2" onkeyup="autotab(this,'ssn3');"
maxlength="2">
<f:validateLength
maximum="2"></f:validateLength>
<hx:validateConstraint
regex="^[0-9]+$"/>
</h:inputText>-

<h:inputText styleClass="inputText" id="ssn3"
size="4" maxlength="4">
<f:validateLength
maximum="4"></f:validateLength>
<hx:validateConstraint regex="^[0-9]+$"
/>
</h:inputText>


Thanks.
--
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.