HtML5 und Regular expressions
In dem A List Apart Artikel Get Ready for HTML 5 habe ich gerade gelesen, dass man in HTML5 input Elementen auch ein pattern Attribut geben kann, sehr praktisch.
HTML 5 extends the input element by offering new attributes that allow you to specify what data you will allow as input. These attributes include min and max (to set a numeric range), and HTML 5 also offers new values for the type attribute, such as url, email, date, and time.
If none of these new input types suits your needs, HTML 5 provides the pattern attribute for input elements with type=”text”. The value of the pattern attribute is a regular expression, as defined in ECMAScript and used in JavaScript.
Beispiel
Enter a US or Canadian Postal Code:
<input type="text" name="postCode"
required="required"
pattern="([0-9]{5}(-[0-9]{4})?)|([0-9][A-Z][0-9]\s+[A-Z][0-9][A-Z])"
title="US: 99999-1234; Canadian: 0A1 B2C" /> 
