Flex:Zipcode验证器无法正常工作

时间:2013-03-01 13:11:51

标签: flash flex flex3 flash-builder

我只想使用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.

1 个答案:

答案 0 :(得分:1)

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

// 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;
}

您可以使用数字验证器吗?在加拿大看起来像邮政编码?