These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

xfa.event.cancelAction = 1; wont work the form still submits.

ajep
Registered: Oct 24 2011
Posts: 15
Answered

form1.#subform[1].Button1::preSubmit:form - (JavaScript, client)
var date1Num = Date2Num(startdate.rawValue,"YYYY-MM-DD")
var date2Num = Date2Num(enddate.rawValue,"YYYY-MM-DD")
if (date2Num <= date1Num) then
xfa.host.messageBox("The End date must be after the Start date.")
xfa.event.cancelAction = 1;
endif

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The "cancelAction" property only works in Acrobat X. What version are you using?

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

ajep
Registered: Oct 24 2011
Posts: 15
I have ADOBE ACROBAT 9 PRO version 9.4.6

So can you please tell me my alternative to this solution if i cant use my code for this problem. I am new to Adobe forms and some psudo code can help me a along the way.

Another question one of my clients who need to sign and submit the form online how i have it embeded in my web page cant do that. I think the problem is that that person has ADOBE ACROBAT Reader 9, is this the problem? If so the only way to submit the form would be to upgrade reader to pro? I need the user to be able to sign the pdf and form because those are my requirements, also other forms will need multuiple signatures. As i understand only by submiting the full pdf you can have the signature. So in my case submiting by XDF, XML, etc is not an option. So just to make sure, is there another way to do this, inorder to avoid buying licenses for pro. I have used IText in the past but again i run in the problem of submitting the whole form with signatures.

Thanks for all your help and time.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
It is never a good idea to use features that only exist in the most recent version, because they won't work for users on older versions. Always wait at least on release cycle.

In the past this issue, canceling the submit was handled in one of two ways.

1. Setting a field to required. The "required" property means that a field must be filled in, i.e., non-null before the form can be submitted. So one solution is to put an empty and invisible field on the form. Then in the pre-submit event, turn on the required feature if you're own validation doesn't pass.

The required feature is actually a field property named "mandatory", look it up. You'll also need to change the mandatory message


2. The second method is to perform the submit operation with a script. You'll find more information on this and examples of two different techniques here.
Modify the LC designer submit



Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Reader is very limited in the type of operations it can perform. As we used to say, it's a reader, not a writer.

However, there are a number of operations that the Reader can perform if, and only if, the target document has been enabled with special Reader Rights. Look on the Advanced menu in Acrobat Pro 9. You'll see an entry for enabling the PDF. Once this is done the user can sign the PDF in Reader.



Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

ajep
Registered: Oct 24 2011
Posts: 15
Thanks for the help!

I have resolved the issue, my clients just need ADOBE ACROBAT 9 STANDARD, with this they can sign and sublit the form. We have licenses already for that, so this is not a problem anymore, just have to wait when we change over to ADOBE ACROBAT X.

I have the above script running in the pre submit action for the submit button. In this script the code checks the values for the dates. I am using FormCalc, but also comfortable with javascript. Anyways thanks for letting me know about the compatability issues. i will investigate what code i need to write so it can work for ADOBE ACROBAT 9 STANDARD. Currently i have the dates as required which works fine, but they must not submit wrong dates. I will post my solution when i solve this issue later.
ajep
Registered: Oct 24 2011
Posts: 15
i still get the generic mandaroty error instead of my custom text

var date1Num = Date2Num(startdate.rawValue,"YYYY-MM-DD")
var date2Num = Date2Num(enddate.rawValue, "YYYY-MM-DD")

if(date2num < date1Num) then
datecheck.mandatory = "error"
datecheck.mandatoryMessage = "The end date must be after the start date"
else
datecheck.mandatory = "disabled"
endif


thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Accepted Answer
The mandatory message really should be setup in LC Designer. There is no reason to set it with code. And in fact, Acrobat might not recognize a change in the message at runtime. There are several LiveCycle parameters that cannot be updated at runtime, this may be one of them.

But really, you're doing this in a very awkward manor, it's very clever, but awkward. If you need to validate the dates it's probably better to do your own submit time validation.

I already posted a link to an article, the sample file for this article has an example of validation on submit.
Modify the LC designer submit

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script