0

I'm searching for something similar to this: https://github.com/7shifts/jQueryTimeAutocomplete

But instead of time, I need some autocompletion/formatting for date. Example: Do you type 23/9, and it's auto format to timestamp format 2014-09-23

Do you know anything?

Ramon Villain
  • 43
  • 1
  • 4
  • Have a look here http://stackoverflow.com/questions/5250244/jquery-date-formatting I think there you can find it – Napokue Sep 22 '14 at 14:44
  • 1
    I'm looking for something like Excel does, you type 23/9, hit tab (or enter) and it'll format to you. But thank you, I'm still searching and gonna try some of this examples – Ramon Villain Sep 22 '14 at 15:10

1 Answers1

0

did it like this.

$("#date").focusout(function(){ var val = $(this).val(); var pieces = val.split('/'); if(!pieces[2]){ pieces[2] = new Date().getFullYear(); } pieces[1] -= 1; console.log(pieces[2]); $(this).val($.datepicker.formatDate('yy-mm-dd', new Date(pieces[2], pieces[1], pieces[0]))); });

Ramon Villain
  • 43
  • 1
  • 4