Expand my Community achievements bar.

SOLVED

setFocus and closeDoc

Avatar

Former Community Member

Hi experts,

I have a form with some required fields.

I've implemented a function that checks for each field (on exit event) if that field was filled or not;

if not, a message is raised and the current field is focused again until it's not filled as expected.

The problem is that, if the user tries to close the document, the check function is executed a lot of times (and the message raised) until adobe reader crashes!

Any suggestion on how to solve that problem?

Best regards.

Dariush.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

If you want to do that you will not be able to take advantage if the validation features that are supplied for you . You will have to write your own validation code for that field on the exit event of you field.

Hope that helps

Paul

View solution in original post

11 Replies

Avatar

Former Community Member

Just providing more info,

here my jscript code for the required field, on exit event.

if (!this.execValidate()) {

                    xfa.host.setFocus(this);

}

This field has an 'Empty message' and 'Validation script message', thus if the execValidate fails a messagebox is reaised by the reader.

any suggestions? Best regards,

Dariush.

Avatar

Former Community Member

If you set the field as required then there is no need to check to see if it is filled or not. Thats what making a field required means. It will not allow you to submit the form until all required fields are filled. If you want to make sure that all fields are filled before a save is done or a print is done then you can put code on the preprint and presave event that will execute all validate events:

form1.execValidate()

Paul

Avatar

Former Community Member

Hi Paul,

thank you for the answer,

I know a form.execValidate can be executed before printing/submitting, the problem is that the form has a large number of fields and the customer would have a direct feedback once the field is exited.

Any best practice regarding?

Ciao, dariush.

Avatar

Former Community Member

So put your code on the exit event and not the validate event ….the validate will fire when the form loads and when the form is submitted …..you are causing all of these additional events to fire for nothing.

Paul

Avatar

Former Community Member

Paul,

my code is in the field exit event, not on validate event.

Take a look please

-------------

PAGE.Page1.w_intcoint::exit - (JavaScript, client)

if (!this.execValidate()) {

                    xfa.host.setFocus(this);

}

---------------

If I try to close the pdf doc while I'm in w_intcoint field and I've not filled the field, the reader shows 2 or 3 times the required message then crashes.

If you want I can send you a quick sample.

Dariush.

Avatar

Former Community Member

Sorry my bad!

I do not like the idea of firing other events to do your code ......why not simply do your validation check on the exit event script?

Paul

Avatar

Former Community Member

I'd not solve the problem.

Once I force the 'focus' on the field until it's not filled, I'm not able to close the doc because selecting file->close, or using [x], the script assigned to that field is runned, the message is raised and the document is not closed immediatly, but only after 2 or 3 messages and after a reader crash.

I don't know at this point if I explained in a proper way my problem, If not Paul tell me, I'll retry :-)

Dariush.

Avatar

Former Community Member

btw,

here an example of what I've implemented.

Surely there's sth wrong, but I don't understand how let this working properly.

http://dl.dropbox.com/u/21852816/test.pdf

Best regards,

Dariush.

Avatar

Former Community Member

You hav eput yourself into an infinite loop ....when you leave the field your exit event fires which causes your validate event to fire but before that is started the cursor is placed back in the field. The message comes up and you click on teh message to dismiss it. This causes the exit event to fire and the whole process starts over again. You can proove this by adding an app alert to the exit and validate event indicating that the event has fired .....there you can see when then evetns are firing and you will see what I mean.

Paul

Avatar

Former Community Member

I see Paul,

this means that the message box raised is not blocking, now I understand.

So, can you suggest me (I'm sure there's a good way) a best practice to check the required field once the user exits from it and force him to stay in that field until the field is filled as expected?

Obvioulsy if the user tries to close the document it should close without an crash.

Let me know please and thank you again.

Dariush.

Avatar

Correct answer by
Former Community Member

If you want to do that you will not be able to take advantage if the validation features that are supplied for you . You will have to write your own validation code for that field on the exit event of you field.

Hope that helps

Paul

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----