This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 18069 - Allow textarea@pattern (input@pattern is specced already so why not)
Summary: Allow textarea@pattern (input@pattern is specced already so why not)
Status: RESOLVED WONTFIX
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: Other other
: P3 enhancement
Target Milestone: ---
Assignee: Robin Berjon
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-18 16:20 UTC by contributor
Modified: 2015-06-26 05:38 UTC (History)
9 users (show)

See Also:


Attachments

Description contributor 2012-07-18 16:20:54 UTC
This was was cloned from bug 15291 as part of operation convergence.
Originally filed: 2011-12-21 07:38:00 +0000

================================================================================
 #0   contributor@whatwg.org                          2011-12-21 07:38:41 +0000 
--------------------------------------------------------------------------------
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html
Multipage: http://www.whatwg.org/C#the-textarea-element
Complete: http://www.whatwg.org/c#the-textarea-element

Comment:
Allow textarea@pattern (input@pattern is specced already so why not)

Posted from: 78.20.165.163 by mathias@qiwi.be
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.14 (KHTML, like Gecko) Chrome/18.0.975.0 Safari/535.14
================================================================================
 #1   Mathias Bynens                                  2011-12-21 09:30:49 +0000 
--------------------------------------------------------------------------------
Use cases for textarea@pattern:

* Enforcing a minimum length. This is probably the most common use case, as pretty much any forum / bulletin board online already does this server-side and/or using JavaScript.
* Tools like http://mothereff.in/ampersands, where the textarea’s text content is validated using a regular expression on-the-fly. Currently this is done separately in JavaScript (since I want to capture the validation errors) but it would be useful to have @pattern work for simple regex-based validation, just so the `invalid` event would fire and the invalid textarea could be targeted using `:invalid` in CSS. The heavier processing (i.e. matching the actual errors) could then be done only when needed. This would result in better performance for the common case where the input is valid.
* Online editors that only allow a specific set of characters, or that disallow a range of characters.
================================================================================
 #2   Lea Verou                                       2011-12-21 09:33:59 +0000 
--------------------------------------------------------------------------------
Yes please.

I just stumbled on this today and was surprised at the lack of @pattern on textareas. 

In my case, it's used for a setting where users enter a "template" (similar to the values that the CSS property grid-template accepts) to control the layout of panes. So I wanted to only allow certain letters and line breaks. My use case was quite specific, but I guess it's part of a more general category of entering structured data in textareas (any kind of regular language that can be matched by a regexp).
================================================================================
 #3   Ian 'Hixie' Hickson                             2012-01-28 22:25:56 +0000 
--------------------------------------------------------------------------------
Single line patterns are very common. It's not clear that multiline text controls with patterns are anywhere near as common.

Before we add this, we should see if authors end up using the validity API to do this in JS often enough to justify adding such a feature.
================================================================================
 #4   Mathias Bynens                                  2012-02-15 20:02:47 +0000 
--------------------------------------------------------------------------------
Pardon my ignorance, but what’s the harm in adding `textarea@pattern`? Several valid use cases have been presented in comment #1 and comment #2.

FWIW, I just ran into some more cases where `textarea@pattern` would’ve been very welcome:

* validating binary input in groups of 8 bits: `pattern="([01]{8})*"`
* extended ASCII input: `pattern="[\x00-\xff]*"`

I needed these for a purely client-side web app: http://mothereff.in/binary-ascii I ended up manually validating the value through JavaScript, adding `class=invalid` to <textarea>s with invalid input.
================================================================================
Comment 1 clb.throw.away 2012-11-06 01:35:47 UTC
I've also run into this, and it seems odd that pattern doesnt exist on textarea.

My use case is long genetic sequences that need to be limited to only the characters A,T,G and C.
Comment 2 Michael[tm] Smith 2015-06-16 11:53:00 UTC
See https://www.w3.org/Bugs/Public/show_bug.cgi?id=15291

It seems unlikely there's ever going to be sufficient implementer interest in this, so we should consider resolving it as wontfix until if/when it ever resurfaces as being important to enough that somebody will take time to re-raise an issue for it.