Topic on Extension talk:TemplateData

Suggestion: Provide input masks

3
197.218.84.226 (talkcontribs)

Use case

As a user, I'd like to guide and validate user input so that each input is always valid.

Background

Input masks provide a way to validate and indicate the exact format of the data entered, for example:

  • Telephone - (___) ____ ____
  • Zip code - ___ ____
  • email, barcode, ISBN, color codes, etc

A good example of this is microsoft word inputmasks or alternatively actual html5 patterns. While it is possible to implement this for each of those, there are an infinite number of ways to require input.

Proposed solution:

Add a new field(s) to templatedata that governs the exact input. For example:

<templatedata>
params": {
    "phone": {
            "label": "Phone",
            "type": "number"
            "inputmask" : "(000) 000-0000",
            "usemask-output" = "false"
     },
}
</templatedata>

Once the page is saved, the input is normalized to the basic wikitext, e.g. "phone = 123123123", and vice versa when the template dialog is loaded. Alternatively, for certain templates it could output it as shown when using the usemask-output parameter.

Whatamidoing (WMF) (talkcontribs)

I don't think that this has been considered before. The team is still wondering when it might be safe to start enforcing much simpler things, such as fields for URLs not containing non-URLs, fields for files not containing non-File: links, etc. This looks like a step well beyond that point.

197.218.88.91 (talkcontribs)

The enforcement should probably be the default, as long as there is a fallback to override it. For instance, probably 80%+ of the world's population has no clue what an ISBN is or what the exact length of it should be.

This would probably resolve a lot of issues that end-users have. There is a often limit to the exact amount of text allowed by most parameters, as such any user adding more than that is likely not inputting it correctly.

Side note: Apparently the page on Input mask did not contain even a single reference (before I added it). Maybe if the editing tool had input masks, more editors would actually know what to add there and how :).

Reply to "Suggestion: Provide input masks"