簡単なコードを探しています
<input type="text" name="year" maxlength="4">
<input type="text" name="month" maxlength="2">
<input type="text" name="day" maxlength="2">
そのため、年を入力し終えると、月、日にフォーカスして停止します。
Google で適切な検索語が見つからないようです。私は、これは1000人によって行われたと確信しています。
簡単なコードを探しています
<input type="text" name="year" maxlength="4">
<input type="text" name="month" maxlength="2">
<input type="text" name="day" maxlength="2">
そのため、年を入力し終えると、月、日にフォーカスして停止します。
Google で適切な検索語が見つからないようです。私は、これは1000人によって行われたと確信しています。
このコードを試してください。これを実現するためにjQueryを使用しました。同じディレクトリにjqueryを含め、各入力に「id」属性を追加する必要があります。
<script src='jquery.js' type="text/javascript"></script>
<input type="text" name="year" id="year" maxlength="4">
<input type="text" name="month" id="month" maxlength="2">
<input type="text" name="day" id="day" maxlength="2">
<script type="text/javascript">
$("#year").bind( 'keypress', function(e) {
if( $("#year").val().length >= 4 )
$("#month").focus();
});
$("#month").bind( 'keypress', function(e) {
if( $("#month").val().length >= 2 )
$("#day").focus();
});
</script>