Monday, August 31, 2009

Re: Validate UK postcode without a space in it

It looks like the Validation regex needs to be updated. This:

$_this->regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]?
[0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';

should be:

$_this->regex =
'/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]?[\s]?[0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';

Ditto for the Canadian one.

On Mon, Aug 31, 2009 at 6:45 AM,
channel5<edd.dawson@comptonsolutions.com> wrote:
>
> Hi
>
> I've got a model that uses
>
> 'rule'=>array('postal',null,'uk')
>
> to successfully validate UK postcodes.
>
> However testing has shown that many people enter their postcodes in
> forms without using the space, so:
>
> W1W 5QU  <-- validates
> W1W5QU  <-- does not validate
>
> Has anyone got any tips on getting the validation to work irrespective
> of whether a user includes or excludes the space?
>
> Thanks
> c5
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: