Copy link to clipboard
Copied
Hey there.
I have a form for naming corporate officers. One company can have 2, another can have 22 so what I would like to do is:
If information is entered into "First Name" then require
"Last Name"
"Title"
"DOB"
Any help is GREATLY appreciated!!!
You are sooo close. Try this.
var sVal = getField("ar_first_name_2").valueAsString;
if (sval != "") {
getField("ar_last_name_2").required = true;
getField("ar_title_position_2").required = true;
getField("ar_dob_2").required = true;
getField("ar_address_2").required = true;
getField("ar_city_2").required = true;
getField("ar_state_2").required = true;
getField("ar_postalcode_2").required = true;
}
Actually, you should use this code, so that required is turned off if the user deletes the first name.
This co
...Copy link to clipboard
Copied
Sorry I should have posted what I tried and failed:
var sVal = getField("ar_first_name_2").valueAsString;
if (inputtx.value.length != 0) {
getField("ar_last_name_2").required = true;
getField("ar_title_position_2").required = true;
getField("ar_dob_2").required = true;
getField("ar_address_2").required = true;
getField("ar_city_2").required = true;
getField("ar_state_2").required = true;
getField("ar_postalcode_2").required = true;
}
and also tried this one to no avail.
var sVal = getField("ar_first_name_2").valueAsString;
if (!sval) {
getField("ar_last_name_2").required = true;
getField("ar_title_position_2").required = true;
getField("ar_dob_2").required = true;
getField("ar_address_2").required = true;
getField("ar_city_2").required = true;
getField("ar_state_2").required = true;
getField("ar_postalcode_2").required = true;
}
Copy link to clipboard
Copied
You are sooo close. Try this.
var sVal = getField("ar_first_name_2").valueAsString;
if (sval != "") {
getField("ar_last_name_2").required = true;
getField("ar_title_position_2").required = true;
getField("ar_dob_2").required = true;
getField("ar_address_2").required = true;
getField("ar_city_2").required = true;
getField("ar_state_2").required = true;
getField("ar_postalcode_2").required = true;
}
Actually, you should use this code, so that required is turned off if the user deletes the first name.
This code is placed in a custom, format or validation script.
var bReq = (event.value != "");
getField("ar_last_name_2").required = bReq;
getField("ar_title_position_2").required = bReq;
getField("ar_dob_2").required = bReq;
...etc...
And since all the lines required the same code. I'd generalize the code into a document level function. This reduces human error when copying the code to all the different lines and makes it much easier to change the code.
Copy link to clipboard
Copied
Thom,
Thank you SOOO much, especially with the extra part of if they go in, type something, and then delete it! You ROCK