Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

validate mandatory fields and cancel submit if blank

Avatar

Former Community Member

I'm new to this and really stuck. How can I require mandatory fields to have a value prior to allowing the user to submit via email? I have a regular control type button that is scripted to email the form, however I want to disallow that if the User-Required fields are blank.  I can get it to validate the fields by placing this in the mouse down event:

if

(form1.execValidate() == false)

{

xfa.host.messageBox("One or more mandatory fields is blank. Please return to the form to complete all fields marked with a *. \n\nThank you!"

, "Form is incomplete", 0, 0);

}

but I can't make the email submission process stop after that. I would most appreciate any help. If I can't figure this out, I guess I will workaround by hiding the submit button until required fields are complete, but I hate to do that when I know there has to be a simple way that's much better!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Sorry.. That was the wrong file..

Here is the correct file..

https://acrobat.com/#d=bYzEuuvdFjiex1HoW8wVxA

Thanks

Srini

View solution in original post

4 Replies

Avatar

Level 10

Here is a sample for you..

https://acrobat.com/#d=HouRLov3lOntSbqAfsr5Hg

Here it checks for the field values before sending the email.

Thanks

Srini

Avatar

Former Community Member

Hi Srini- Thanks so much for your response, however, the sample you posted doesn't seem to validate or stop the submission. When I clicked the button, it continued to pull the form into an email with null values. Maybe this is a problem on my end? I do appreciate your help!

Avatar

Correct answer by
Level 10

Sorry.. That was the wrong file..

Here is the correct file..

https://acrobat.com/#d=bYzEuuvdFjiex1HoW8wVxA

Thanks

Srini

Avatar

Former Community Member

Awesome! Thats perfect - thank you so much. You saved the rest of my hair from being

pulled out