0

我只想使用 Flex 的 ZipCode 验证器验证加拿大邮政编码。我是这样做的:

<mx:ZipCodeValidator
        id="zipCodeTextInputFieldValidator"
        domain="{ZipCodeValidatorDomainType.CANADA_ONLY}"
        source="{this.zipCodeTextInputField}" 
        property="text" 
        triggerEvent=""
        wrongCAFormatError="The Canadian postal code must be formatted 'A1B 2C3'."
    />

发布它也验证美国邮政编码。如果我给出923 424了邮政编码,它会抛出验证错误说The ZIP code must be 5 digits or 5+4 digits.

4

1 回答 1

1

编辑:在源代码 ZipCode 验证器检查字符串长度:

// do an initial check on the length
if ((len < 5 || len > 10) || (len == 8) || 
    (!containsLetters && (len == 6 || len == 7)))
{
    // it's the wrong length for either a US or Canadian zip
    results.push(new ValidationResult(
        true, baseField, "wrongLength",
        validator.wrongLengthError));
    return results;
}

你可以使用数字验证器吗?加拿大的邮政编码如何?

于 2013-03-01T13:31:50.967 回答