Web Forms 2.0 - regular expressions

This is part of a suite of test forms for Web Forms 2.0 for a set of shared examples with XForms Transitional. See the corresponding XForms Transitional example. This demo will only work on a Web Forms 2.0 compliant browser (e.g. Opera 9).

Patterns

Here is the markup for the above form:

<form name="form1" onsubmit="false">
<fieldset>
<legend>Patterns</legend>
<label for="f1"
title="must resemble 1234-1234-1234">Card number</label>
<input id="f1" name="cardnum" value="1234-1234-1234"
pattern="^\d\d\d\d-\d\d\d\d-\d\d\d\d$">
</fieldset>
</form>

For this example, the same markup also works with XForms Transitional. To my joy, the field immediately turns red when the input doesn't match the pattern. This uses the same style rule that failed to have any effect on example 1.

Dave Raggett <dsr@w3.org>