dimanche 20 août 2017

VAT Number HTML5 Pattern

So I've got to validate European VAT numbers when a user registers. I've got the following pattern set:

^((AT)?U[0-9]{8}|(BE)?0[0-9]{9}|(BG)?[0-9]{9,10}|(CY)?[0-9]{8}L|(CZ)?[0-9]{8,10}|(DE)?[0-9]{9}|(DK)?[0-9]{8}|(EE)?[0-9]{9}|(EL|GR)?[0-9]{9}|(ES)?[0-9A-Z][0-9]{7}[0-9A-Z]|(FI)?[0-9]{8}|(FR)?[0-9A-Z]{2}[0-9]{9}|(GB)?([0-9]{9}([0-9]{3})?|[A-Z]{2}[0-9]{3})|(HU)?[0-9]{8}|(IE)?[0-9]S[0-9]{5}L|(IT)?[0-9]{11}|(LT)?([0-9]{9}|[0-9]{12})|(LU)?[0-9]{8}|(LV)?[0-9]{11}|(MT)?[0-9]{8}|(NL)?[0-9]{9}B[0-9]{2}|(PL)?[0-9]{10}|(PT)?[0-9]{9}|(RO)?[0-9]{2,10}|(SE)?[0-9]{12}|(SI)?[0-9]{8}|(SK)?[0-9]{10})$

And I'm also clarifying it in the placeholder/title that they need to: Enter VAT Number: CC0123456789 which includes the CC (Country Code).

However clients still don't seem to understand this and still fill in the VAT number without the Country Code and the pattern doesn't seem to check this if a country code has been entered.

So for example I want people to always enter the country code and their vat number accordingly. As it is now you can either enter BE0123456789 or 0123456789 but the latter is something I specifically do not want.

Is there a way to have the above pattern to force use the Country Code?

Thanks in advance for further information.

Aucun commentaire:

Enregistrer un commentaire