smartclient

DynamicForm validation - accept Validator_A OR Validator_B


My DynamicForm field has 2 validators for zip code

[
    { type: "mask", errorMessage: "Invalid postal code", mask: "^(\\s*\\d{5}\\s*)(\\s*-?\\s*\\d{4}\\s*)?$", transformTo: "$1-$2" },
    { type: "mask", errorMessage: "Invalid postal code", mask: "^\\s*([A-Z]{1}\\d{1}[A-Z]{1})\\s*(\\d{1}[A-Z]{1}\\d{1})\\s*$", transformTo: "$1-$2" }
]

The first is for the United States, the 2nd is for Canada. Is It possible to set the field up to accept either option as valid input?


Solution

  • this answer is a bit old but I think it's still valid.