When using 3 text boxes for date form
I have have date form on my web page and it is just 3 text boxes, 1 for day 2nd for month and开发者_开发知识库 3rd for year as dd/mm/yyyy. What I wana do is when some one enters two digits for the day the cursor should automatically jumps to the month text box , and then to the year text box i.e instead of clicking or hitting tab button......I was messed up with it this after noon and can't finish it. lol. Any help!
Try this little bit of JS:
function moveToNext(field,nextFieldID){
if(field.value.length >= field.maxLength){
document.getElementById(nextFieldID).focus();
}
}
and then add this to your fields:
<input type="text" id="dd" maxlength=2 onkeyup="moveToNext(this,'mm')"/>
<input type="text" id="mm" maxlength=2 onkeyup="moveToNext(this,'yyyy')"/>
<input type="text" id="yyyy" maxlength=4 />
精彩评论