Skip to content

Input

Supersonic includes a set of helper utilities for working with form inputs.

Restricts an input field to numeric characters only. This is useful for phone numbers, postal codes, age fields, and other numeric-only values.

The helper removes any non-digit character from the input value as the user types. It is intended for lightweight client-side filtering and should not replace server-side validation.

<input id="zip-code" type="text" />
<script>
window.supersonic.init();
window.supersonic.ui.onlyAllowNumbers('#zip-code');
</script>
ArgumentTypeDescription
elementSelectorstring | nullOptional CSS selector for the input element. If omitted, the helper uses the current event target.
<input id="age" type="text" />
<script>
const input = document.getElementById('age');
input.addEventListener('input', () => {
window.supersonic.ui.onlyAllowNumbers('#age');
});
</script>