Dealing with empty form fields in email
I'm a total beginner and I have "elementary shcool" level of Javascript knowledge.
With google's help, I was able to get a button, that sends an email with custom subject and body using data from the fields in the form, working.
Where I have a problem is when checking if a field is empty. The form has 3 field names.
First one is always filled out so I don't need to check. 2nd and 3rd ones however I need to check if they are empty so I can include them in the email or not.
When I use the code below the script doesn't even run when I press the button which leads me to think that there's an error and that's why it doen't run.
Besides of "valueAsString" I have also tried just "value" but I get the same result.
I also tried the === instead of the ==
Any ideas what I'm doing wrong?
The code I use is:
var RR2Name = this.getField("RR1Name").valueAsString;
var RR2Name = this.getField("RR2Name").valueAsString;
var emailSubject;
if (RR2Name =="") {
emailSubject = RR1Name + " form"
} else {
emailSubject = RR1Name + " and " + RR2 + " form"
}