Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 497
homer5677 Avatar asked May 15 '14 11:05

homer5677


People also ask

What is the attribute type for ZIP Code?

You can use the maxlength attribute to set the maximum number of characters (works on all browsers) and additionally a pattern attribute what specifies the allowed characters and combinations, too; its value naturally depends on the zipcode type(s) to be used.

What is the input type for ZIP Code in HTML?

HTML input fields used for Zip Codes should be type=text and use the pattern attribute to provide hints to the browser · GitHub.

What is ZIP Code format?

The most complete ZIP Code is a nine-digit number consisting of five digits, a hyphen, and four digits, which the USPS describes by its trademark ZIP+4. The correct format for a numeric ZIP+4 code is five digits, a hyphen, and four digits.


1 Answers

You can try this

<Label>ZIP Code</Label><input type="text" pattern="[0-9]{5}" title="Five digit zip code" /> 
like image 122
Md Johirul Islam Avatar answered Sep 28 '22 02:09

Md Johirul Islam