i use this one:

 Order.PC.requires =
IS_MATCH('^([A-Za-z][0-9][A-Za-z]\s*[0-9][A-Za-z][0-9])$',
         error_message=T('Not a valid Postal Code')), IS_NOT_EMPTY()


you can also try some of these others that I have, but the one above works
fine...

  # validate Canadian Postal Codes
    # CA: ^(?!.*[DFIOQU])[A-VXY][0-9][A-Z]●[0-9][A-Z][0-9]$
    # CA: ^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$
    # CA: [ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d
    # CA: ^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z][ ]\d[A-Z]\d$
    # UK: ^[A-Z]{1,2}[0-9R][0-9A-Z]?●[0-9][ABD-HJLNP-UW-Z]{2}$
    # US: '^[0-9]{5}(?:-[0-9]{4})?$'




On Mon, Sep 24, 2012 at 9:13 PM, Don_X <don.clerm...@gmail.com> wrote:

> Hello web2py users :
>
> Validating if numbers or decimals are entered on a form seem to be very
> straight forward and easy enough ! whether it is a phone number or a US
> postal code :
> Like for example a US postal code would go like this :
>
> requires = IS_MATCH('^\d{5}(-\d{4})?$',error_message='not a zip code')
>>
>>
> however, a Canadian postal code on the other hand is another story :
>
> a Canadian postal code is configured like this : Letter#Letter #Letter#
> an example would be : A1B 2C3, or A1B-2C3, or again A1B2C3  :  All these 3
> postal codes are the same and equivalent in the Canadian postal code scheme
> !
>
> How would I go about validating such input into a field on a form in
> python / web2py ???
>
> it seems that there is no easy simple way to do this ! ... is there a set
> of alphabetic characters only .... without numbers in python / web2py ?  I
> only found alpha numeric characters that take numbers as characters !! and
> it is not what I want !! ..
>
> Please help !
>
> thank you
>
> Don
>
>  --
>
>
>
>

-- 



Reply via email to