2 Replies - 324 Views - Last Post: 24 April 2012 - 04:33 PM

#1 xythian  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 03-April 12

form not advancing focus automatically

Posted 24 April 2012 - 03:52 PM

this is a reinforcement exercise that i am toying with, or it is toying with me i am not sure. Either way
i cannot get it working. It is supposed to advance the focus automatically after maxlength has been
achieved but no luck.
any suggestions would be helpful, thanks

<html>
<title>Auto Next Field</title>
<head>
<h1>Info</h1>
</head>
<body>
<script type="text/javascript">
function nextField() {
if (document.form[0].box1.value.length == document.form[0].box1.maxlength)
document.forms[0].box2.focus();
}
</script>
<form action="FormProcessor.html" method="get" enctype="application/x-www-form-urlencoded">
<p>
Enter your social security number:<br>
<input type="text" name="box1" size="4" onkeyup="nextField(this, document.forms[0].box2)" maxlength="3" />
<input type="text" name="box2" size="3" onkeyup="nextField(this, document.forms[0].box3)" maxlength="2" />
<input type="text" name="box3" size="5" maxlength="4" />
</p>
</form>
</body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: form not advancing focus automatically

#2 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: form not advancing focus automatically

Posted 24 April 2012 - 04:16 PM

nextField isn't actually set to receive arguments. Why pass them to it?
Was This Post Helpful? 0
  • +
  • -

#3 xythian  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 03-April 12

Re: form not advancing focus automatically

Posted 24 April 2012 - 04:33 PM

I have tried using this and several other formats to no avail.
function nextField(document.form[0].box1, document.form[0].box2) {


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1