[whatwg] Re: Web Forms 2.0

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