<!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>
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
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
10