Dating yourself
After being dissatisfied with the complexity of JavaScript date widgets, I wrote this snippet to create a natural language solution, backed by the Datejs library. It works by parsing the text a user entered on blur.
It's a little rough at the moment, but a few refinements could make it just as effective as some of the more complicated implementations out there.
It's a little rough at the moment, but a few refinements could make it just as effective as some of the more complicated implementations out there.
$('input.datefield').blur(function () {
var field = $(this);
var date = Date.parse(field.val());
if (date) {
field.val(date.toString("hh:mm tt"));
}
});

0 Comments:
Post a Comment