Easy date entry into form inpu

DateBox.js¶ ↑ by Jakob Kruse <kruse@kruse-net.dk>¶ ↑

For easy date entry into form input elements.

Based on¶ ↑

A rewrite by Will Rickards (2005-02-04) of:

‘Magic’ date parsing, by Simon Willison (6th October 2003) simonwillison.net/2003/Oct/6/betterDateInput/

Usage¶ ↑

DateBox.register(obj);

Where ‘obj’ is an <input type=“text” /> element, or the id of one.

What you get¶ ↑

The input field will recognize date formats such as:

today

tomorrow

yesterday

last tuesday

next saturday

4

4th jan

4th jan 2010

jan 4

jan 4 2010

1-4

1-4-10

1-4-2010

2010-4-1

… or variantions thereof depending on the chosen locale. Also:

Double-clicking the field (when empty) will insert todays date

Scrolling the mouse wheel while hovering the field (when not empty) will increase or decrease the date

Pressing <up> or <down> in the field (when not empty) will increase or decrease the date

A span will be created dynamically after the input element. The span will use the CSS classes ‘DateBoxControlMsg’ and ‘DateBoxControlErrorMsg’. This span will contain either a formatted date (according to your browser locale), or an error message if the contents of the input can’t be parsed, or is not a valid date.

History¶ ↑ 1.5¶ ↑

First release on github.

Added localization support, English and Danish locales.

Removed external dependencies.

Chrome and Safari support.

Doubleclick inserts todays date.

Supports both US and European date formats (not at the same time though)

1.4¶ ↑

Some date formats gave errors in Mozilla, now fixed.

Added mouse wheel scroll handling.

1.3¶ ↑

Empty input no longer shows error.

1.2¶ ↑

Added a few new formats.

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。