Classify the value before choosing the keypad
A mobile form may ask for a quantity, a telephone number, a verification code and a customer reference. All four may look like digits on screen, but they are different kinds of data. Quantity is a number on which arithmetic and limits may make sense. A phone number is contact information that may include a prefix, spaces or punctuation. A verification code and reference are identifiers, for which a leading zero may be essential. Choose the input control from that meaning first; then choose a keyboard hint that makes entry convenient. This prevents a neat-looking form from silently changing the customer's answer.
Mozilla's input number guidance reserves that control for incremental numbers, particularly where a spinbutton helps. It explicitly warns against using number for digit-looking identifiers such as postal or card numbers. A shop's quantity field can reasonably be numeric if customers select whole units and the rules are clear. A shipment reference, even if it currently contains only digits, should usually remain text because it is copied, compared and stored rather than calculated. Do not treat browser rendering of a numeric field as a guarantee that users cannot type an invalid value. Validate on the server against the business rule as well.
The inputmode attribute is a keyboard hint, not a data rule. Mozilla's reference says it can encourage a suitable virtual keyboard but does not impose validity requirements. For a text identifier made of digits, inputmode numeric may make entry easier while leaving the stored value as text. Do not assume every device displays an identical keypad or that a hint blocks a pasted letter. Users may have hardware keyboards, assistive technology, or autofill. Separate the visible hint, accepted characters, normalization and server validation in the field specification instead of asking a single HTML attribute to do all four jobs.
Telephone numbers need their own treatment. The tel input type can prompt a telephone keypad, but Mozilla notes that it does not automatically validate a universal phone format because formats vary. A Hong Kong business may primarily serve local numbers while still receiving overseas contacts. Decide which destinations the service really supports and state that scope beside the field. If international contacts are accepted, allow a usable country code path rather than forcing everyone into a fixed local pattern. Store the number in a deliberate canonical form while preserving enough context to show the customer what they entered.
Apply the rule to a real form
Imagine a small retailer's mobile pickup form. It asks for item quantity, a contact telephone number and a six-character pickup code. For quantity, decide whether zero is allowed, whether fractions are meaningful, and whether there is an upper stock or order limit. Only after those decisions should a numeric control and step size be chosen. The displayed error must tell the customer the accepted range and preserve the entered value so it can be corrected. A browser minimum or maximum can help the interface, but final acceptance belongs to the server that owns inventory and order policy.
For the phone field, provide a visible label and example appropriate to the accepted scope. Avoid making the placeholder the only instruction, because it disappears during entry. Preserve a leading plus sign where an international number is allowed; do not coerce the value into arithmetic. Test copying a number with spaces, pasting it, editing one digit and returning to the field after an error. If the business sends a message or makes a call, a confirmation step may be necessary for that workflow, but input type alone cannot prove the number belongs to the customer.
A pickup code illustrates why digit-only does not mean numeric. Suppose the illustrative code is 004281. If it is stored as a number, leading zeros disappear and comparison with the printed or messaged code can fail. Treat it as text, with an explicit length and allowed-character rule. A numeric keyboard hint may be reasonable if every valid character is a digit, but do not split the code into many single-character boxes unless the team can support paste, focus movement and correction reliably. Give the whole code a clear label, and handle an expired or wrong code as a distinct state.
Some fields change their rules with the customer's selection. A chosen delivery destination may affect the telephone format or which address components are required; a selected product may affect quantity increments. Recalculate the relevant rule when the choice changes and explain the new requirement near the field. Do not silently clear a valid answer unless there is a strong reason, and never transform an identifier by stripping zeros merely to fit a numeric component. Test the transition from one option to another, because a form that validates correctly on first load can fail after a customer changes their mind.
Test entry, correction and stored result
Write a field matrix before implementation. For each field record whether its value is a count, contact value or identifier; whether leading zeros, signs, separators or decimals are legitimate; its expected keyboard hint; its visible instruction; its client and server validation; and its stored representation. This makes disagreements visible before they become production bugs. Product owners should approve the actual allowed values, not an abstract promise that the form is “mobile friendly.” Developers can then choose HTML semantics that match the agreed rule rather than fitting a rule to a convenient widget.
Test on at least the mobile browsers the business actually supports, and include an external keyboard or desktop route where customers use one. Enter a value by tapping, pasting, autofill where applicable and editing in the middle. Submit empty, malformed and boundary values. Confirm that the keyboard offers needed characters, but also that the field remains usable if it does not. A numeric keypad without a minus or decimal key can obstruct a legitimate value, while a phone keypad may not suit an identifier containing letters. The right test is the complete accepted value set, not a screenshot of one attractive keypad.
Review errors in English and Traditional Chinese as separate customer instructions. A message such as “invalid number” is poor when the field is an identifier or when the error is simply a missing country code. State what needs changing, where, and why if the reason affects the decision. After a failed submission, keep the customer's other answers where safe and let them correct the problem in place. Check that assistive technology receives the field label, requirement and error together. This work complements a general form error flow; it focuses on the underlying value and control choice.
Finally inspect the submitted record, not just the on-screen form. Compare the entered telephone, quantity and code with the value received by the server and displayed to staff or the customer. A form can look correct yet lose a leading zero during serialization, apply a default numeric step that rejects a valid amount, or accept a phone string the downstream message service cannot use. If the backend rejects a value, return a precise correction path without turning it into a different value silently. Release when the same intended answer survives entry, validation, storage and later use.
Be careful with money and measurements as well. A price adjustment or weight may be a genuine numeric value, but its permitted precision, separators and rounding rules must come from the business process. A decimal keyboard hint can help, yet devices may present different separators, and a pasted value may not follow the local display convention. Show the unit beside the field and specify how the value is interpreted before final submission. Do not let an interface silently round a customer-entered amount into a different commercial commitment. Test the displayed value, the submitted value and the later confirmation side by side. This is the same principle as for quantities: keyboard convenience comes after a clear definition of the value and its allowed range.
Before release
- Quantity rules, contact formats and identifier lengths are documented separately.
- Leading zeros and legitimate symbols survive submission and storage.
- Both language interfaces and supported devices pass paste and error correction tests.


