You are here: irt.org | FAQ | JavaScript | Form | 2 | Q335 [ previous next ]
Only in Netscape Navigator 4 or Internet Explorer 4:
<head>
<script language="JavaScript"><!--
function KeyPress(what,e,max,action) {
if (document.layers) {
if (e.target.value.length >= max)
eval(action);
}
else if (document.all) {
if (what.value.length > (max-1))
eval(action);
}
}
//--></script>
</head>
<body>
<form>
<input type="text" name="text1" size="1" maxlength="1" onKeyUp="KeyPress(this,event,1,'what.form.text2.focus()')">
- <input type="text" name="text2" size="2" maxlength="2" onKeyUp="KeyPress(this,event,2,'what.form.text3.focus()')">
- <input type="text" name="text3" size="3" maxlength="3" onKeyUp="KeyPress(this,event,3,'what.form.text4.focus()')">
- <input type="text" name="text4" size="4" maxlength="4" onKeyUp="KeyPress(this,event,4,'what.form.text5.focus()')">
- <input type="text" name="text5" size="5" maxlength="5" onKeyUp="KeyPress(this,event,5,'what.form.text6.focus()')">
- <input type="text" name="text6" size="6" maxlength="6" onKeyUp="KeyPress(this,event,5,'what.form.text6.focus()')">
</form>
</body>Johan Sundström writes:
Additional restraint on where it works: Netscape Navigator on Unix (at least 4.75 and below) don't succeed in doing this using just an onKeyUp handler.