Here is the code to address your first question. I added a class attribute for convenience and replaced the "maxlength" attribute by the HTML "size" attribute.
HTML
<p><input type="text" class="navigable" id="txt1" data-number="1" size="2" placeholder="dd"></p>
<p><input type="text" class="navigable" id="txt2" data-number="2" size="2" placeholder="mm"></p>
<p><input type="text" class="navigable" id="txt3" data-number="3" size="4" placeholder="yyyy"></p>
JS
$('.navigable').keyup(function() {
var self = $(this);
var next = $('#txt'+(self.data('number')+1));
if(next.length > 0 && self.val().length == self.attr('size')) {
next.focus();
}
});
I have my doubts concerning your request about the arrow keys binding. What happens if the user wants to navigate in one of the inputs? Nevertheless, here is the code to take into account the arrow keys:
HTML
<p><input type="text" class="navigable" id="txt1" data-number="1" size="2" placeholder="dd"></p>
<p><input type="text" class="navigable" id="txt2" data-number="2" size="2" placeholder="mm"></p>
<p><input type="text" class="navigable" id="txt3" data-number="3" size="4" placeholder="yyyy"></p>
JS
$('.navigable').keyup(function(e) {
var self = $(this);
var currentInput = self.data('number');
var next = $('#txt'+ (currentInput + 1));
var previous = $('#txt'+ (currentInput - 1));
var keyCode = e.keyCode || e.which;
if(next.length && keyCode === 40)
next.focus();
else if(previous.length && keyCode === 38)
previous.focus();
else if(next.length && self.val().length == self.attr('size')) {
next.focus();
}
});