// form1.page1.subform1.telephone::exit - (JavaScript, client)
// validat formats include 1234567890, (123)456-7890 and (123) 456-7890
var regex = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
var str = this.rawValue;
if (regex.test(str)) {
var areaCode = "";
regex = /^\d{10}$/;
if (regex.test(str)) {
// format is 1234567890
areaCode = str.substring(0,3);
if (areaCode == "204" || areaCode == "431") {
str = "(" + str.substring(0,3) + ") " + str.substring(3,6) + "-" + str.substring(6,10);
this.rawValue = str;
}
else {
xfa.host.messageBox("The area code must be either 204 or 431.");
}
}
else {
// format is (123)456-7890 or (123) 456-7890
areaCode = str.substring(1,4);
if (areaCode == "204" || areaCode == "431") {
this.rawValue = str;
}
else {
xfa.host.messageBox("The area code must be either 204 or 431.");
}
}
}
else {
xfa.host.messageBox("Please enter the telephone number in the format 1234567890, (123)456-7890 or (123) 456-7890.");
}
Steve