Hello,
Right now I have a postal code field set up to allow a certain format. Right now it will only let the user enter letters, numbers and spaces. I want to put a restriction on the field so that the user cannot enter a space in the field. I am having problems doing this though. Below is the script I am using in the EXIT event. Please let me know if you can offer any help.
Thank you,
NikDK
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 without spaces. The postal code must begin with R.");
}
else {
var regExp = /^([R]\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 without spaces. The postal code must begin with R.");
}
}
}
Solved! Go to Solution.
Views
Replies
Total Likes
You can try placing the below code in Change event with java Script.
This will restrict the input to numbers and letters only.
if (xfa.event.change.match(/[0-9\A-Z\a-z]/) == null)
xfa.event.change = "";
Thanks
Srini
Views
Replies
Total Likes
You can try placing the below code in Change event with java Script.
This will restrict the input to numbers and letters only.
if (xfa.event.change.match(/[0-9\A-Z\a-z]/) == null)
xfa.event.change = "";
Thanks
Srini
Views
Replies
Total Likes
Thank you Srini! it worked!
Views
Replies
Total Likes
now here's another question about the postal code field. I want the user to enter only 6 characters. If i put that restriction in then because of the space, it counts the space as one of the 6 characters and cuts off one of the letters or numbers. If I change it to allow 7 characters, then the user can enter the whole 7 characters, but I only want them to enter 6. Does this make sense?
Views
Replies
Total Likes
Views
Likes
Replies