[whatwg] Re: Web Forms 2.0

Ian Hickson ian at hixie.ch
Fri Oct 7 12:53:39 PDT 2005

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 (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 

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list