Copy link to clipboard
Copied
I am hoping to add some validation in to check whether certain fields are null if some are filled out. Unfortunately just using the required field isn't enough for this as I don't want to always make it mandatory, I just want to make certain fields mandatory if some are filled out. For example:
Email Address
Description
Both of the above fields are optional, however if a description is entered I want to validate that there is also a value for Email Address on submitting the form. I have this part of the script complete I believe.
I am hoping for some assistance on how to only submit the form if the validation passes. At the moment I have it set up as two different mouse up actions (Run a Javascript & Submit a Form) meaning that they're independent of eachother and it still submits the form even when the validation fails and an alert is brought up. So I am seeking help in writing the submit a form logic in my JavaScript file if anyone can lend a hand.
Copy link to clipboard
Copied
Is the submit action configured to submit by email or to a web server? In any case, you'd just have to use the equivalent JavaScript method (e.g., submitForm) and not use the submit form action. In your scipt, you'd check the fields, and if everything's OK, allow the submit to take place, and otherwise don't.
Copy link to clipboard
Copied
Basically you would use something like this:
var condition1 = ...;
var condition2 = ...;
var condition3 = ...;
if (condition1 && condition2 && condition3) this.mailDoc({cTo: "me@server.com"});
else app.alert("You must first do X, Y and Z before submitting the form.",1);