timepoint-selection

npm install timepoint-selection var selection = require('timepoint-selection');

Enhance input elements with easy key entry and validation for time durations.

Library is in pure javascript, no framework is needed. Event handlers are added directly to the input and the package includes a destroy method to remove all added events.

Input numbers directly or increment and decrement with up and down arrow keys.

Left and right arrow keys navigate through the input selecting the next important character for entry.

Rollover is automatically handled.

Tabbing into an element automatically selects the first character in the input for easier entry.

Non-valid characters are prevented from input.

Can provide custom separators for display.

hh:mm:ss max 99:59:59

selection(document.getElementById("ex1"));

hh:mm:ss max 23:59:59

selection(document.getElementById("ex2"), { 'durationFormat': 'hh:mm:ss', 'max': 3600 * 24, 'useAbbr': true, 'abbr': { 'hh': 'h ', 'mm': 'm ', 'ss': 's' } });

hh:mm max 99:59

selection(document.getElementById("ex3"), { 'durationFormat': 'hh:mm', 'value': 3600 * 2 + 60 * 30, 'useAbbr': true });

hh:mm max 11:59

selection(document.getElementById("ex4"), { 'durationFormat': 'hh:mm', 'max': 3600 * 12 });

dd:hh:mm:ss max 99:23:59:59

selection(document.getElementById("ex5"), { 'durationFormat': 'dd:hh:mm:ss', 'useAbbr': true, 'abbr': { 'dd': 'days ', 'hh': 'h ', 'mm': 'm ', 'ss': 's' } });

dd:hh:mm max 99:23:59