Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Setting for as invalid

Avatar

Former Community Member
hi,



is there a way i can set a form as invalid with script.



when i return false from my initialize event, on submit button, the form seems to gothrough anyway.



is there a build in function i can use?



Thanks!
4 Replies

Avatar

Former Community Member
On the "Click" event, you can have a script like this



if (SomeObject.rawValue != "something you want")

{

app.alert("Can't submit");

exit;

}



let me know if this works

Avatar

Former Community Member
it still attempts to send the document with the exit;



basically, becuase there is no validation for the checkboxes, i'm doing it manually on the validate event in the submit button via javascript.



my logic is this:



- if the rest of the form is valid aka all required fields are filled in, check for the check boxes (this works)



- if the check boxes are all empty - show a message and don't submit (this is the part where it keeps submitting, no matter if i return true or false)



i'm confused. please help :(



my submit button (validate event) looks like this:



if (myscripts.validateForm())

{

xfa.host.messageBox("returned true - submit form")

}

else

{

xfa.host.messageBox("returned false - display error and exit")

exit;

}



the value i'm getting from validateForm (true or false) is correct.

Avatar

Former Community Member
oh, and after putting exit; in, i get a javascript error back saying "exit is not defined"

Avatar

Former Community Member
Have you saved you form as a "Adobe Dynamic XML" ?



Make sure you have chosen the language JavaScript and not FormCalc.