npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

age-picker

v1.2.0

Published

Enhance `input` tags for collecting age information using `data-` attributes and simple wireup JavaScript.

Readme

Age Picker

npm

Enhance input tags for collecting age information using data- attributes and simple wireup JavaScript.

Try out a demo!

Example

Example

Installation

npm install age-picker

Or, load this script manually: https://unpkg.com/age-picker@latest/lib/age-picker.min.js -- This targets the latest version, which may include breaking changes for major version updates. A specific version can be targeted to avoid potential breaking changes. See https://unpkg.com for more information.

Quickstart

<label for="age">Age or DOB</label>
<input type="text" id="age" name="age" data-age-picker />

<label for="direct-entry-only-age">Age or DOB (direct entry only)</label>
<input type="text" id="direct-entry-only-age" name="direct-entry-only-age" data-age-picker-direct-entry-only />
new AgePicker().init();

Usage

  • Decorate input tags with a data-age-picker or data-age-picker-direct-entry-only attribute.
  • Run new AgePicker().init();, optionally specifying the scope in the parameter (defaults to document.body).

Configuration options can be specified in the AgePicker constructor. Example:

new AgePicker({
  selectClasses: ['form-control']
}).init();

Configuration options

| Option | Description | Default Value | | ------------------------------ | ------------------------------------------------------------------------- | ------------- | | defaultDomScope | The default DOM scope to scan for dataAttribute items. | document.body | | dataAttribute | The data- attribute to scan for. | 'data-age-picker' | | directEntryOnlyDataAttribute | The data- attribute to scan for supporting direct entry only. | 'data-age-picker-direct-entry-only' | | useDateAttribute | The data- attribute to transmit the date, rather than the age. | 'data-age-picker-use-date' | | prefixClass | The prefix for CSS classes used by other configuration CSS classes. | 'age-picker' | | containerClass | The container class surrouding the age picker and all related DOM assets. | ${this.configuration.prefixClass}-container | | monthSelectClass | The select tag to select the month. | ${this.configuration.prefixClass}-month | | daySelectClass | The select tag to select the day. | ${this.configuration.prefixClass}-day | | selectClasses | An array of custom classes to apply to month and day select elements. | [] | | i18n | Internationalization data, defaults to US English. | { months: [...] } |

Methods

init(domScope = this.configuration.defaultDomScope)

Scan the domScope and wire up any elements matching this.configuration.dataAttribute.

create(element)

Create the age picker assets targeting element. Used by init().

Events

Note: Events should be used rather than listening for keyup, change, etc. on the <input data-age-picker> tag, since a hidden input becomes the source of truth for the over-the-wire 'age'.

ageChanged

Raised on the input element when the age is changed or cleared by any forms of user input (both direct entry and year, month, day inputs). This event includes the age value.

Notes

Our use cases dictate collecting the month and day from the user. However, other or future use cases may allow for using today's date. By using today's date with a provided year age could be calculated. This feature does not currently exist, but was considered.

Currently supports Gregorian calendar using English language only. Additional languages can be supported by overriding the i18n configuration.

Development

  • npm install
  • npm run build or npm run watch, then open demo/index.html in a browser.
  • npm test to run tests.
  • npm run lint to run linter.

License

MIT