Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Validate form before submitting

Avatar

Level 1

Hi Guys,

I have asked similar before but cant figure this out.

I have a form with mainly mandatory fields. There are two fields which are invisble unless 'other' is selected.

I have created a submit button which creates a email with the pdf as attachemrent. I am trying to get the submit button to validate the form before submitting. I cannot tell it to look at individual fields because if someone does select 'other' the visible fireld which appears becomes mandatory. I just need the form to check that everything has been filled in before the email is generated.

I have tried execValidate befoe and that doesnt seem to do anything.

3 Replies

Avatar

Level 10

https://drive.google.com/file/d/0Bz8yb5apn8y4a1RUY1R0R0RSbWs/edit?usp= sharing

Try this validation instead of using mandatory fields...

I've created this PDF to show how to use validation with a method I made myself... Look in the script objects to see what it does...

Really easy to use and gives you many opportunities for different validation on different forms

All you have to do is write what you want to do in a button, and the script object validates everything for you!

Avatar

Level 1

Thanks for that Robert. How then do I deal with 'other' fields. For example if in a location dropdown box i select 'other' another box appears for the user to type in the address and thbis becomes mandatory - how would this be implemented into the validation process.

Avatar

Level 10

As long as a field is visible in your form, the validation method will consider the field as mandatory, unless you specify its name in the exception table.

So if you choose other in your dropdownlist and you put the field address visible, it will become mandatory

if another option is chosen and the field address is hidden it will not validate the field