Hi all :)
Made this sweet little script to auto change fields after input. Works nicely in IE, Chrome and Safari, but not in FF or opera.
JS code:
function fieldChange(id, e){
var keyID = (window.event) ? event.keyCode : e.keyCode;
if (document.getElementById(id).value.length >= 2){
if (keyID >= 48 && keyID <= 57 || keyID >= 96 && keyID <= 105){
switch(id){
case "textf1":
document.getElementById("textf2").focus();
break;
case "textf2":
document.getElementById("textf3").focus();
break;
case "textf3":
if (document.getElementById(id).value.length >= 4){
document.getElementById("nubPcode").focus();
}
break;
}
}
}
HTML:
<div class="privateOrderSchema">
<input type="text" id="textf1" name="textf1" maxlength="2" size="4" onKeyUp="fieldChange('textf1')"/>-
<input type="text" id="textf2" name="textf2" maxlength="2" size="4" onKeyUp="fieldChange('textf2')" />-
<input type="text" id="textf3" name="textf3" maxlength="4" size="5" onKeyUp="fieldChange('textf3')" />
</div>
<div class="privateOrderSchema">
<input type="text" id="nubPcode" name="nubPcode" size="4" maxlength="4" />
<br />
</div>
Does anybody know how to send the "e" var in this scenario?
Tnx all :D ur gr8!