- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Someone please Help. Pulling hair out here. Trying to get this to work.
My goal is to have the following patterns
456-7990 with the result adding "(701)" 456-7890
4567990 with the result adding "(701)" 456-7890
1234567890 with the result (123) 456-7890
123 456 7890 with the result (123) 456-7890
(123)456-7890 with the result (123) 456-7890
(123) 456-7890 with the result (123) 456-7890
I know the code is ugly I've tried mashing code I've found around the forum. I can't get the form1.Page1.telephone::exit - (JavaScript, client)
to work. I have tried making it so with the code below and adding patterns
text{'('999')' 999-9999}|text{'('999')'999-9999}|text{999999-9999}|text{999-999-9999}|text{999'-'9999999} to the edit part.
and just text{'('999')' 999-9999} to the display. I limited the length to 14 which gives and error that "The number of symbols in the specified pattern does not match the maximum number of characters".
I was also trying to incorporate if(str.indexOf(")") > -1)" to replace any "." that people may enter The incorporating isn't a huge deal
but I just need to the end result to be "(123) 456-7890" and the page is already packed to I can't add a separate box for area code.
form1.Page1.telephone::exit - (JavaScript, client)
if (!(this.isNull)) {
var str = this.rawValue;
var regExp2 = /^(\d{3})[-](\d{4})$/;
var regExp = /^\d{10}$/;
var regExp1 = /^\d{7}$/;
if (regExp1.test(str)) {// For input 1234567 for format (123) 456-7890
this.rawValue = "701" + str;
m = 1;
}
if (regExp2.test(str)) {// For input 123-4567 for format (123) 456-7890
this.rawValue = "(701) " + str;
m = 1;
}
if (m == 1) {
this.rawValue = "(" + str(0,3) + ") " + str(3,3) + "-" + str(6,4);
}
if (regExp.test(str)) {
this.rawValue = "(" + str.substr(0,3) + ") " + str.substr(3,3) + "-" + str.substr(6,4);
}
else {
regExp = /^[1-9]\d{2}\s\d{3}\s\d{4}$/;
if (regExp.test(str)) {
this.rawValue = "(" + str.substr(0,3) + ") " + str.substr(4,3) + "-" + str.substr(8,4);
}
else {
regExp = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
if (!(regExp.test(str))) {
xfa.host.messageBox("Please enter the telephone number in the format '(999) 999-9999'.");
this.rawValue = null;
xfa.host.setFocus(this);
}
}
}
}
Views
Replies
Total Likes