LoginSignup
1
0

More than 5 years have passed since last update.

the sample of that put the focus on the next text when you input 2 digit

Last updated at Posted at 2018-02-22
<!DOCTYPE html>
<!-- [ published at 2018-02-22 20:27:13 ] -->
<html>
<script type="text/javascript">
function test(strText) {

  // AAAA含んでいる場合、
  if(strText.includes("AAAA")){
      // フォーカス元のnameを取得する
      var newstrText=strText.replace('AAAA','');
      // フォーカス元を取得する
      var n = document.getElementsByName(newstrText);
      // 2けた入力すると、
      if(n[0].value.length== 2){  
         // 次のテキストを選択する
          n[0].nextElementSibling.focus();
      }
  }

}
</script>
<head>
<body>

<input type="text" name="test1" class="cheadSeaKey" maxlength="2" value="" onkeyup="test('test1AAAA')" />

<input type="text" name="test2" class="cheadSeaKey" value="b" />


<!-- start dmp -->

</body>
</html>
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0