I have a form with several fields to which users (employees) need to enter their working hours. The grand total (a read only field) must be 40. I relied on FormClac to enter the SUM function.
I want to prevent users from submitting the form if the total is less or more than 40 but I do not want them to constantly get an error message (while filling out the form) if the grand total is not 40. I want the error message to appear only if they try to submit the form and to prevent them from sending the form if the grand total is not 40.
I do not really know much about JavaScript so I would really appreciate it if someone could send me an example.
Thanks,
Yaniv
Solved! Go to Solution.
Views
Replies
Total Likes
Use xfa.host.messageBox().
See Designer help at http://livedocs.adobe.com/livecycle/8.2/acrobat_designer/wwhelp/wwhimpl/js/html/wwhelp.htm
For messageBox method, specifically, see http://livedocs.adobe.com/livecycle/8.2/acrobat_designer/001720.html
Steve
Views
Replies
Total Likes
Ok. I was able to figure this one out (http://forums.adobe.com/message/1944044#1944044 - pguerett) on validate:
if ((this.rawValue >= 0) && (this.rawValue <= 40)){
true
} else {
false
}
However, how can I change the error message from Validate failed to something else. How do I insert the alert into this script?
I would greatly appreciate your help.
Views
Replies
Total Likes
Use xfa.host.messageBox().
See Designer help at http://livedocs.adobe.com/livecycle/8.2/acrobat_designer/wwhelp/wwhimpl/js/html/wwhelp.htm
For messageBox method, specifically, see http://livedocs.adobe.com/livecycle/8.2/acrobat_designer/001720.html
Steve
Views
Replies
Total Likes
Yes. Thank you again Steve!
if ((this.rawValue >= 0) && (this.rawValue <= 40)){
true
} else {xfa.host.messageBox("The total cannot be more than 40!");
false
}
But the validate error message also pops up after my xfa message?! Is there something more I am supposed to do?
Views
Replies
Total Likes
Remove 'true' and 'false' from your validation script. If you look at the Value tab for the object, you probably have Error checked for the Validation Script Message. I believe the presence of 'true' in your validation script causes the built-in validation to fire.
How about...
if (!(this.isNull || this.rawValue.length == 0)) {
if (this.rawValue > 40) {
xfa.host.messageBox("The total cannot be more than 40!");
}
}
OK. The script didn’t work. It did not identify the error and even when I unchecked the Validation Script Message, I still got the Validation message.
But your answer did give me the solution. I took my xfa message and placed it in the validation message box and now the user gets ONE error message and with the message I wanted to send him.
I am trying to do the same thing with the Sunday date issue. I added a false commend to prevent submission and placed the xfa message in the Validation box. In this case, for some reason the validation doesn’t work.
if (!(this.isNull || this.rawValue.length == 0)) {
if (this.rawValue != "Sun") {
xfa.host.messageBox("The selected date is not a Sunday.");
false
}
}
I didn’t sleep all night trying to fix these issues and now it all looks so much better… I am simply grateful for your help!!!
Views
Replies
Total Likes
I of course had to change the Type to read only but since user override is not allowed I don’t see why this should be a problem.
Views
Replies
Total Likes
Views
Likes
Replies