inputtype

command
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Command inputtype upgrades generic text inputs to email, tel and url where the field's name says what it holds - and, more often, declines to.

<input name="email">        ->  <input name="email" type="email">
<input name="phone">        ->  <input name="phone" inputmode="tel">

The difference between this and examples/gip/autocomplete is the difference between a hint and a behaviour. An autocomplete token tells a browser what a field means; a type tells it what the field does. Changing one changes validation, the on-screen keyboard, what a stylesheet matches and what a script finds:

type="email"   the form will not submit an address without an @, and the
               value is trimmed on submit
type="url"     the form will not submit anything but an absolute URL, so a
               field where people type "example.com" stops working
type="tel"     no validation, and a telephone keypad - the safe one
               (which is why tel exists rather than number)

So the bar is not "the name probably means an email address", it is "this change cannot break the page". Four things can, and each is a refusal with a count rather than a guess:

A pattern attribute. The field already has validation, and the type brings its own; whether they agree is not something this program can work out.

A value that the new type would reject. <input name="email" value="tbc"> becomes a form that cannot be submitted until the user fixes a field they did not fill in. Checked for what is checkable: an email needs an @, a url needs a scheme.

A page that styles or scripts on the type. If a stylesheet in the document says input[type=text], or a script does, then changing the type changes the page in a way this program cannot see the end of - so it looks, in the document's own <style> and <script> content, and refuses if it finds it. That evidence can be anywhere, which is why this reads the document twice: the question is about the whole page, like the one in examples/gip/landmarks.

A url upgrade at all, unless asked. type="url" is the one whose validation people meet daily and lose to, so it needs -url.

Where the type is refused or not attempted, the safe half of the benefit is still available: inputmode changes the on-screen keyboard and nothing else. A field that gets no type gets an inputmode, which is why this program's usual output is a keyboard rather than a validator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL