Usage

HTML (Auto-init)

HTML
<input type="text" class="fw-timepicker" id="myTime">

<script>
  FormWidgets.autoInit();
</script>

HTML with Data Attributes

HTML
<input type="text" class="fw-timepicker"
       data-show-seconds="false"
       data-show-pattern="true">

JavaScript Initialization

JavaScript
FormWidgets.init('#myTime', 'TimePicker', {
    format: 'HH:mm',
    showSeconds: false,
    showPattern: true
});

Options

OptionTypeDefaultDescription
formatstring'HH:mm:ss'Time format string. Use HH:mm:ss for 24-hour with seconds, or HH:mm without seconds.
showSecondsbooleantrueWhen false, the seconds selector is hidden and the format defaults to HH:mm.
showPatternbooleantrueWhen true, the expected time format is shown as a placeholder (e.g. HH:mm:ss).
iconstring'ult">falseWhen true, the field is required and shows a validation error when empty.

Data Attributes

ed="true"
Data AttributeEquivalent OptionExample
data-show-secondsshowSecondsdata-show-seconds="false"
data-show-patternshowPatterndata-show-pattern="true"
data-iconicondata-icon="clock"

Keyboard Navigation

Enter / Open the time picker popup
EscClose the picker and return focus to the input
TabNavigate through hours, minutes, seconds selectors and the Apply button
Increment or decrement values in focused selector
EnterApply the selected time and close the picker

Manual Input

Users can type a time directly (e.g. 14:30 or 09:15:00). The widget validates and formats on blur.

Features

Dropdown Selectors

Separate scrollable selectors for hours, minutes, and seconds.

Manual Input

Type times directly — validated and formatted on blur.

Optional Seconds

Show or hide the seconds selector as needed.

Smart Positioning

Popup positions above or below based on available screen space.

Notes

Format and showSeconds

When you set showSeconds: false, also set format: 'HH:mm' to ensure the stored value matches the display. If they conflict, the format string takes precedence.