Pak RT’s 17 August T-shirt form: type into a real <input> and read back its value (what type reaches JS?), valueAsNumber, ValidityState and the browser’s…
A comfortable phone form makes a real difference: the wrong keyboard means typos and people giving up halfway through checkout. The right type gives the right keyboard, free validation and autofill without JS. Yet it also sanitises the value: number throws away "+62", and value stays a string.
The right type is the cheapest UX win there is
el.value from type="number" turns out a string, not a number input.value is always a string, even when the type is number. Use input.valueAsNumber (NaN when empty) or Number(input.value) before doing sums.+62 country code rejected by a type="number" field number sanitises +, spaces and dashes to an empty string. Use type="tel" (a phone pad, the value as typed), or type="text" inputmode="numeric" for codes like an OTP.[email protected] still passes type="email" validation The built-in check only looks at the rough format (an @ and a domain). Still verify for real on the server; the type is only the first line of defence and UX.validity.badInput lights up and value becomes an empty string: the browser keeps your typing, yet JS cannot read it.type="emial" input.type becomes "text": an unknown type falls back to the default with no error.type="text" + inputmode="numeric": a digit keyboard, yet the value stays text, leading zeros safe.reportValidity() brings up the browser’s own bubble with its validationMessage.