Put the script in the exit event of the ContactNo. So when the contact not empty it will make both the Name fields as mandatory.
Then in the exit event of both FirstName, Last name check which Name field has value, according to that make the other one mandatory and show message.
In the contact no exit event put the script
var lv_contactno = xfa.resolveNode("xfa.form.data.MainSubform.Contact02Subform.CNTCTNODR PDWN2").rawValue;
if (lv_contactno != null)
{
xfa.resolveNode("data.MainSubform.Contact02Subform.FAVOR").mandatory = "error";
xfa.resolveNode("data.MainSubform.Contact02Subform.FANAM").mandatory = "error";
}
In the exit event of this FirstName put the script
if (this.rawValue == null)
{
if (FNAM.rawValue == null) // If both the values are null then prompt the use to fill either one.
{
app.alert("Please fill either the firstname or the last name");
}
else
{
FAVOR.mandatory = "disabled"; // Make the FirstName as optional
}
}
else
{
FNAM.mandatory = "disabled"; // Make the lastname field as optional
}
Similarly in the exit event of this LastName put the script
if (this.rawValue == null)
{
if (FAVOR.rawValue == null) // If both the values are null then prompt the use to fill either one.
{
app.alert("Please fill either the firstname or the last name");
}
else
{
FNAM.mandatory = "disabled"; // Make the LastName as optional
}
}
else
{
FAVOR.mandatory = "disabled"; // Make the firstname field as optional
}
Hope this helps.
Thanks,
Bibhu.