Skip to main content
Inspiring
May 15, 2025 2:55 PM UTC
Answered

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

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!

try67
try67Correct answer
Community Expert
May 15, 2025 4:01 PM UTC

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;
}

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 15, 2025 4:01 PM UTC

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;
}
Translate
kyle_7624Author
Inspiring
May 15, 2025 4:06 PM UTC

That works absolutely perfect, thanks so much!

Translate