Hello,
I currently have a feild that is set up for postal codes. The user enters a 6 digit number without spaces, in a format of A3A 3A3 (letter, number, letter, number, letter, number). When the user tabs over, it automaticallly displays the space inbetween. I am wondering if it is possible to have the field only allow postal codes that begin with R or S, and if so, how would I achieve this.
Thank you in advance for your help,
Nik
Solved! Go to Solution.
The problem was related to mixing validation patterns and validation error handling with custom validation scripting. Display and validation patterns and validation error handling had to be removed for the script to work properly.
Steve
Views
Replies
Total Likes
Try this...
// form1.page1.subform1.postalCode::exit - (JavaScript, client)
if (!(this.isNull)) {
var str = this.rawValue;
if (str.length != 6) {
xfa.host.messageBox("Please enter a six character postal code in the format A9A9A9.");
}
else {
var regExp = /^([RS]\d[A-Z]\d[A-Z]\d)$/i;
if (regExp.test(str)) {
str = str.toUpperCase();
this.rawValue = str.substring(0,3) + " " + str.substring(3,6);
}
else {
xfa.host.messageBox("Please enter the postal code in the format A9A9A9, where the postal code must begin with R or S.");
}
}
}
Steve
HI Steve, thank you again for your help. This seems to be working to an
extent. If I put in the correct postal code format, I am still getting an
error message.
Views
Replies
Total Likes
Please disregard the previous email. It seems to be working fine now. Not
sure why. Thanks again for all of your help.
Views
Replies
Total Likes
Nope i was wrong, its not working. It brings up a error message even if you enter the correct format. Any suggestions?
Views
Replies
Total Likes
If you can send the form to stwalker.adobe@gmail.com I'd be happy to take a look.
Steve
Views
Replies
Total Likes
The problem was related to mixing validation patterns and validation error handling with custom validation scripting. Display and validation patterns and validation error handling had to be removed for the script to work properly.
Steve
Views
Replies
Total Likes
Hi Steve,
I'm wondering how I would restrict the field from allowing symbols.
Views
Replies
Total Likes
Help - I created a field for postal codes last year and cannot for the life of me remember how to do it again
Views
Replies
Total Likes
Maybe look at validation patterns? Which country (or countries) are you targeting?
Views
Replies
Total Likes
Hi - it's okay. I don't need a validation pattern, was just struggling with formatting it so it would work correctly. It is now. Thanks
Views
Replies
Total Likes