B
BudAtLitho
This is in my form:
<input type="text" name="form_home"
onblur="f5(this.form,name)"value="<?=$mnhome?>" size="20"
maxlength="20" style="font-family: arial, helvetica, sans-serif;
border-width: 1px; font-size: 8pt; border-top-style: solid; border-
right-style: solid; border-bottom-style: solid; border-left-style:
solid; ">
My function is:
function f5(form,name){//Format phone number
var entry = eval("form."+name+".value")+"";
// alert("entry= "+entry);
var form_name= "form."+name+".value";
// alert(form_name);
if(entry == "") return
if(entry.length < 10){
alert("Please enter complete phone number including area code!");
}
else {//extract numbers from string
var newnumber = "";
var t = entry.length;
for(i=0; i<t; i++){
if(entry.charAt(i)!= "-"&&entry.charAt(i)!= ")"&&entry.charAt(i)!=
"("){
newnumber += entry.charAt(i);
}
}
}
// alert(newnumber);
form.+eval(name)+.value =
"("+newnumber.charAt(0)+newnumber.charAt(1)+newnumber.charAt(2)+")
"+newnumber.charAt(3)+newnumber.charAt(4)+newnumber.charAt(5)+"-"+newnumber.charAt(6)+newnumber.charAt(7)+newnumber.charAt(8)+newnumber.charAt(9);
}
If fails to pass the new value back to the form, as I can't get the
syntax right to refer to the form field name using the variable. I
can get it to work if I replace form.+eval(name)+.value with
form.form_home.value but I want to use this function with many phone
number fields.
Thanks in advance for any help.
<input type="text" name="form_home"
onblur="f5(this.form,name)"value="<?=$mnhome?>" size="20"
maxlength="20" style="font-family: arial, helvetica, sans-serif;
border-width: 1px; font-size: 8pt; border-top-style: solid; border-
right-style: solid; border-bottom-style: solid; border-left-style:
solid; ">
My function is:
function f5(form,name){//Format phone number
var entry = eval("form."+name+".value")+"";
// alert("entry= "+entry);
var form_name= "form."+name+".value";
// alert(form_name);
if(entry == "") return
if(entry.length < 10){
alert("Please enter complete phone number including area code!");
}
else {//extract numbers from string
var newnumber = "";
var t = entry.length;
for(i=0; i<t; i++){
if(entry.charAt(i)!= "-"&&entry.charAt(i)!= ")"&&entry.charAt(i)!=
"("){
newnumber += entry.charAt(i);
}
}
}
// alert(newnumber);
form.+eval(name)+.value =
"("+newnumber.charAt(0)+newnumber.charAt(1)+newnumber.charAt(2)+")
"+newnumber.charAt(3)+newnumber.charAt(4)+newnumber.charAt(5)+"-"+newnumber.charAt(6)+newnumber.charAt(7)+newnumber.charAt(8)+newnumber.charAt(9);
}
If fails to pass the new value back to the form, as I can't get the
syntax right to refer to the form field name using the variable. I
can get it to work if I replace form.+eval(name)+.value with
form.form_home.value but I want to use this function with many phone
number fields.
Thanks in advance for any help.