Search code examples
htmlformsvalidation

What html5 form attribute should be used for a zipcode?


Is it best to use a 'text' attribute with a limit on the number of characters, or can I use a number attribute in an input for a zipcode.

Just trying to get my head around all the different attributes with the forms in html5. Cheers


Solution

  • You can try this

    <Label>ZIP Code</Label><input type="text" pattern="[0-9]{5}" title="Five digit zip code" />