W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2005

[whatwg] Re: Web Forms 2.0

From: Ian Hickson <ian@hixie.ch>
Date: Fri, 7 Oct 2005 19:53:39 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0510071948470.23945@dhalsim.dreamhost.com>
On Fri, 7 Oct 2005, Ryan Cannon wrote:
> 
> e.g.:
> 
> <input type="text" required="required" notPattern="First Name\s*" 
> value="First Name" />
> 
> I hope it is not too late in this versions timeframe to bring such 
> functionality in, as it seems impossible right now.

You can do this today with:

   pattern="(?!First Name\s*)"

...which would match any field that did not match /First Name\s*/. See 
section 15.10.2.8 (page numbered 147) of ECMA-262 3rd edition for more 
details on the (?!...) negative look-ahead assertion.

Note however that a better way to do this is:

   <label>First Name: <input required></label>

Your original example fails if the person's first name is really "First 
Name", and doesn't semantically indicate that the text field is expecting 
a first name (it says its default value is "First Name", which is very 
different).

HTH,
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 7 October 2005 12:53:39 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:43 UTC