Skip to main content

View Post [edit]

Poster: TechLord Date: Feb 3, 2024 1:02am
Forum: general Subject: Automatic date field for uploader (JavaScript code included)

Because I am so thankful for the Archive, I wrote this code. After entering the year in the uploader, it will automatically go to the month, and then automatically to the day. This means that the user needs to simply type "20101220" to enter 2010-12-20, not "2010[tabulator]12[tabulator]20".

Simply add this to the JavaScript code:


function numberpress(keycode) /* checks whether last pressed key is a number so it goes to the next field only then */ {
if(keycode >= 48 && keycode <= 57) /* number row */ return true;
if(keycode >= 96 && keycode <= 105) /* num pad */ return true;
else return false;
}

date_year.addEventListener("keyup", function(key){if (date_year.value.length == 4 && numberpress(key.keyCode) ) { date_month.focus(); } } );
date_month.addEventListener("keyup", function(key){if (date_month.value.length == 2 && numberpress(key.keyCode) ) { date_day.focus(); } } );


I hope this improvement will be implemented.

Again, thank you for this amazing library.