私はこのHTMLコードを持っています:
<form name="postcode" method="post" onsubmit="return OnSubmitForm();">
<input class="postcode" maxlength="1" size="1" name="c" onKeyup="autotab(this, document.postcode.o)" />
<input class="postcode" maxlength="1" size="1" name="o" onKeyup="autotab(this, document.postcode.d)" />
<input class="postcode" maxlength="1" size="1" name="d" onKeyup="autotab(this, document.postcode.e)" />
<input class="postcode" maxlength="1" size="1" name="e" /> <br />
</form>
このJavaScriptを使用します:
<script>
/*
Auto tabbing script- By JavaScriptKit.com
http://www.javascriptkit.com
This credit MUST stay intact for use
*/
function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}
</script><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
<script src="js/scripts.js" type="text/javascript"></script>
<script type="text/javascript">
function OnSubmitForm()
{
if(document.postcode.operation[0].checked == true)
{
document.postcode.action ="plans.php";
}
else
if(document.postcode.operation[1].checked == true)
{
document.postcode.action ="plans_gas.php";
}
else
if(document.postcode.operation[2].checked == true)
{
document.postcode.action ="plans_duel.php";
}
return true;
}
</script>
テキスト ボックスの 1 つに 1 つの文字を入力するとすぐに、次のテキスト ボックスに自動的に移動します。
これは、PC または Mac、Safari、および他のすべてのブラウザーで問題なく動作します。ただし、iPad または iPhone (Safari を使用) で Web ページを表示する場合、自動タブ移動機能は機能しません。
これらのモバイル デバイスで自動タブを機能させる方法について何かアイデアはありますか?