Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Validation of Canadian Postal Codes

Avatar

Level 2

Canadian postal codes follow the A9A 9A9 format.

In my display validation pattern, I have  text{A9A 9A9}

In my edit validation pattern, I have text{A9A 9A9}|text{A9A9A9}

In my validation pattern, I have text{A9A 9A9}

I also have a JavaScript validation running client side.

It reads:

form1.#subform[0].Section1.PostalCode::validate - (JavaScript, client)

this.rawValue = this.rawValue.toUpperCase();

Given these paramaters, I am stumped as to why I keep getting the following validation error: "The value you entered for Postal Code in valid."

Any thoughts?

0 Replies

Avatar

Level 10

Your uppercase code should be on the exit event of the field. The validation pattern works by testing against the display pattern.

Or you could put xfa.event.change = xfa.event.change.toUpperCase(); on the change event of the field.

Avatar

Level 1

Try this:

event.value = event.value.toUpperCase();

if(event.value != "")

{

// validate Canadian postal code;

event.rc = /^(?!.*[DFIOQU])[A-VXY][0-9][A-Z][0-9][A-Z][0-9]$/.test(event.value);

if(event.rc == false)

{

  app.alert("Please enter a correct Canadian Postal code", 1, 0);

  this.resetForm([event.target.name]);

}

}