( Being a JS rookie as I am, I am really tempted to just use ONE input field and handle all of that in one quick swift in PHP which is much my element . But I also want to try and learn living with JS. )
Using the jquery-ui-timepicker-addon.js , I need to divide the input to the respective fields year,month,day,hour,minutes..
I found some other similar questions here on SE , but they involve only the normal UI time picker ,which provides only the year,month,day triple ( never really understood why)..
However, using those resources , I "hacked" something that almost works, but the problem is that the field that is being clicked to trigger the picker is always getting filled with ALL the values ...
DEMO : http://jsfiddle.net/obmerk99/9Tk69/2/
Now, going a bit further, I have managed to divide also the hour:minute
pair ..
DEMO : http://jsfiddle.net/obmerk99/9Tk69/3/
But still some problems remain ..
1 - This must be the ugliest code in human history ( or at least JS ) - there must be a better ways of doing it .. If someone presented me an equivalent PHP code I would be mortified.
2 - the Input field that is getting triggered still get ALL the input ..
3 - It work ok only if TIME is touched . if the DATE alone is set , the timesplit[0]
will be undefined...
4 - I can not get BOTH to work, the minute a DATE Or Hours OR second is clicked - the focus is lost .
EDIT I
This is basically @Steve Wellens answer,
getYear() should be changed to getFullYear..
The problem of the first field trigger still remains ( get full values ) on blur, and also - it works only if ALL values are touched .. ( if you do not change the hour, it will be blank)
At this point, I think that using ONE field and split with PHP will be my best option ( along with HTML5 for the few who have it ).
Ended up considering this ..