Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Conditional Required Fields and Validation

Avatar

Level 1

Sorry this is a bit long!

I am trying to create a travel request form using Adobe LiveCycle v9. First, I was able to set up some conditional fields (where if the user was to click "Yes", then other fields would become required, too). I used this script for the buttons under a "change" event:

if

(this.rawValue =='1')

{

Acc_Check_In.mandatory

= "error";

Acc_Check_Out.mandatory

= "error";

Acc_City.mandatory

= "error";

Acc_Check_In.validate.nullTest

= "enabled";

Acc_Check_Out.validate.nullTest

= "enabled";

Acc_City.validate.nullTest

= "enabled";

}

else

{

Acc_Check_In.mandatory

= "disabled";

Acc_Check_Out.mandatory

= "disabled";

Acc_City.mandatory

= "disabled";

Acc_Check_In.validate.nullTest

= "disabled";

Acc_Check_Out.validate.nullTest

= "disabled";

Acc_City.validate.nullTest

= "disabled";

}

However, I have run into the problem that when I click the "submit" button (a regular button that is scripted to send an email with the pdf attached), there is no validation whether or not the required fields have something entered there. Under the "click" event, I have the following script:

var

strToAddress, strSubject, strMessage

strToAddress

= "example@example.com";

strSubject

= "Flight Request for " + First_Name.rawValue + " " + Last_Name.rawValue;

strMessage

= "Please find travel request form attached.";

event.target.submitForm({cURL

:"mailto:"+ strToAddress + "?subject=" + strSubject + "&body=" + strMessage,cSubmitAs:"PDF",cCharset:"utf-8"});

//this.resolveNode("#event").submit.target = "mailto:"+ strToAddress + "?subject=" + strSubject + "&body=" + strMessage;

The extent of my knowledge is what I gleaned from the forums, so any help would be greatly appreciated!

Thanks,

Michelle

1 Reply

Avatar

Level 9

Hi Michelle,

In the click event of the submit button you can put some scripts to check whether the run time required value or not.

You can wrap all those fields in a subform which need to be run time required. And can call the execValidate() function before submitting the form.

For ex : if (Acc_Check_In.execValidate() )

                 {

                      Script for submitting the form.

                 }

           else

               {

                     app.alert("Please fill the required fields");

               }

Thanks,

Bibhu