본문 바로가기

스크립트/Keyboard관련

폼 자동 탭넘기기

<script language="javascript" type="text/javascript">
<!--
function NextTab(oMe, oNext, iLen)
{
  if (oMe.value.length == iLen) { oNext.focus(); }
}
//-->
</script>

----html------------------------
<form name="frmQuizAnswer" id="frmQuizAnswer" method="post" >
<input type="text" name="q1a1" id="" maxlength="5" "NextTab(this, frmQuizAnswer.q1a2, this.maxLength)" />
<input type="text" name="q1a2" id="" maxlength="4" "NextTab(this, frmQuizAnswer.q1a3, this.maxLength)" />
<input type="text" name="q1a3" id="" maxlength="3" "NextTab(this, frmQuizAnswer.q1a4, this.maxLength)" />
<input type="text" name="q1a4" id="" maxlength="2" />
</form>

 

 

maxlength의 크기만큼 입력이 되면 다음 폼으로 자동으로 넘어갑니다.