I have total of 11 check boxes that I want to be mandatory. With being maddatory I want to throw an error message when you click the submit by Email button just in case all the fields werent checked. Basically I don't want the end user submitting the form without properly checking all the boxes. I decided to run two Java scripts.
first java script for each check box which is a initialize event
this.mandatory = "error";
this.mandatoryMessage = " must view the terms and conditions.
second script
(I made sure to hide and exclude the orginal email sumbit button, and place a "fake" submit button.
used a click event on the fake submit button
if(checkbox1.rawValue ! = "1", checkbox2.rawValue ! = "1",etc......)
{
xfa.host.message (" must view the terms and conditions");
}
else
{
EmailSubmitButton1.execEvent("click");
I'm running into a problem with the second script. Problem is when not all 11 boxes are checked it shows the error message before opening Email (which I want). But if you only check couple the boxes and leave couple not checked it dosent show the error message (which I dont want to happen) just goes straight to email. I don't want the email popping up if boxes are unchecked, I want the error message showing if check boxes have yet to be checked. I feel im close with solving this problem.
Your if statement logical test statement does not have the correct syntax for a logical OR or AND test. I am assuming you want a logical OR test.
There is no 'xfa.host.message()' method.
Assuming the "Off" value for the check boxes is numeric 0:
// see if any check box is not checked
if(checkbox1.rawValue == 0 | checkbox2.rawValue == 0 |checkbox3.rawValue == 0 | (...) | checkbox11 == 0){
// an unchecked box has been found
xfa.host.messageBox(" must view the terms and conditions");
} else {
// all check boxes checked
EmailSubmitButton1.execEvent("click");
}
George Kaiser