5 Replies - 488 Views - Last Post: 01 August 2014 - 06:54 AM

#1 healdprice  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-August 14

What is the best way of form validation in HTML5 for zip input type?

Posted 01 August 2014 - 06:06 AM

Hello, I have just read the article Form validation in HTML5 and I am wondering what the best way is to validate zip code in input field using only form validation in HTML5. I probably need a regular expression to cover the most common format for zip code.
Is This A Good Question/Topic? 0
  • +

Replies To: What is the best way of form validation in HTML5 for zip input type?

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,257
  • Joined: 08-June 10

Re: What is the best way of form validation in HTML5 for zip input type?

Posted 01 August 2014 - 06:15 AM

Quote

I probably need a regular expression to cover the most common format for zip code.

correct. and unless all the browsers of your users support this type of validation, it cannot be considered the "best way".
Was This Post Helpful? 0
  • +
  • -

#3 healdprice  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-August 14

Re: What is the best way of form validation in HTML5 for zip input type?

Posted 01 August 2014 - 06:21 AM

yes, I know, but I want to use HTML5. Can you help me with a regular expression for this?

I don't know the common formats which can be applied in the most cases. I need it for a registration form on some website.

This post has been edited by Dormilich: 01 August 2014 - 06:21 AM
Reason for edit:: removed previous quote

Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,257
  • Joined: 08-June 10

Re: What is the best way of form validation in HTML5 for zip input type?

Posted 01 August 2014 - 06:22 AM

View Posthealdprice, on 01 August 2014 - 03:21 PM, said:

I don't know the common formats which can be applied in the most cases.

me neither.
Was This Post Helpful? 0
  • +
  • -

#5 ge∅  Icon User is offline

  • D.I.C Addict

Reputation: 80
  • View blog
  • Posts: 564
  • Joined: 21-November 13

Re: What is the best way of form validation in HTML5 for zip input type?

Posted 01 August 2014 - 06:50 AM

Quote

but I want to use HTML5


Why ?

Use Javascript. And if you have no clue what pattern to use, just drop the functionality or use a Geo database containing city names, ZIP codes and states, and provide your users with filtered drop-down menus that will help them fill your form quickly.

Don't implement any form of data validation if you're not 200% sure you cover every possible cases. There is nothing more exasperating than being unable to send a form filled with valid informations because your formatting doesn't meet the dev's arbitrary and capricious requirements or because the guy doesn't know your town or anything as stupid as that.
Was This Post Helpful? 0
  • +
  • -

#6 healdprice  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 01-August 14

Re: What is the best way of form validation in HTML5 for zip input type?

Posted 01 August 2014 - 06:54 AM

ok, thanks anyway!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1