Legs
Legs

Reputation: 41

Rewrite date/time format with jQuery

I have be looking around for a solution for this but cant find anything. I am trying to reformat the date and time entered into a form, ideally with jQuery. I am not using the datepicker. I am trying to rewrite dates so they come out in the format “dd/mm/yyyy” so if the user enters “050812”, “05082012”, “05-08-2012” etc the date gets rewtirred to “dd/mm/yyyy”. I am also trying to achieve this with time fields so the format will be “hh:mm”.

What would be the best way to achieve this?

Thank you

Upvotes: 0

Views: 752

Answers (1)

Frias
Frias

Reputation: 11291

As @eicto said, datepicker is the best option.

But if you really want another way:

To show the to the user what's the right way to enter data: http://jsfiddle.net/bmSPs/1/ To mask the input: http://digitalbush.com/projects/masked-input-plugin/

OBS: If you want a more powerful way to control the hour you could also use http://keith-wood.name/timeEntry.html

Upvotes: 1

Related Questions