I am trying to build a full name from three fields (First, MI, and Last). If the middle initial field is blank, I do not want a period to appear in the assembled name. My code is below and when the MI field is blank, a period still appears between the first and last names. The partial_name is not being applied in this case.
// Get field values
var F_Name = this.getField('First_Name').value;
var M_Name = this.getField('MI').value;
var L_Name = this.getField('Last_Name').value;
// Build full_name string
var full_name = F_Name + " " + M_Name + ". " + L_Name;
// Build Partial Name string
var partial_name = F_Name + " " + L_Name;
if(M_Name="") {event.value = partial_name;
}
else {event.value = full_name;
}
// Get field values
var F_Name = this.getField('First_Name').value;
var M_Name = this.getField('MI').value;
var L_Name = this.getField('Last_Name').value;
// Build full_name string
var full_name = F_Name + " " + M_Name + ". " + L_Name;
// Build Partial Name string
var partial_name = F_Name + " " + L_Name;
if(this.getField('MI').value=="") {
event.value = partial_name;
// I think that's because you used single (=) instead of (==) or (===) and you //wrote If with a capital I
}
else {event.value = full_name;
}