Skip to main content
Inspiring
May 15, 2025
Answered

Requiring text field 1 or 2, but both can be filled out.

  • May 15, 2025
  • 1 reply
  • 370 views

Hello All,

 

Currently trying to prepare a new hire form that would be asking to enter their bank account numbers for their paycheck. I'm wanting to require them to fill out at least 1 of 2 fields asking for either their checking or savings number but the company allows them to deposit a percentage into each account if they wish so to be able to fill out both text fields optionally. Just wondering how I could go about requiring either field, but allowing the option to fill out both. Thanks!

Correct answer try67

Let's say the fields are called "Account1" and "Account2". Add the following code to the custom Calculation event of the first one:

 

var otherField = this.getField("Account2");
if (event.value=="") {
	if (otherField.valueAsString=="") {
		event.target.required = true; 
		otherField.required = true;
	} else event.target.required = false; 
} else {
	otherField.required = false;
}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 15, 2025

Let's say the fields are called "Account1" and "Account2". Add the following code to the custom Calculation event of the first one:

 

var otherField = this.getField("Account2");
if (event.value=="") {
	if (otherField.valueAsString=="") {
		event.target.required = true; 
		otherField.required = true;
	} else event.target.required = false; 
} else {
	otherField.required = false;
}
kyle_7624Author
Inspiring
May 15, 2025

That works absolutely perfect, thanks so much!