Expand my Community achievements bar.

Validation of all form fields xfa.form.execValidate ()

Avatar

Level 2

Hello  everyone.

I would execute validation form via xfa.form.execValidate(); in click event of button.
In formular i have many inputs (text, number,  ... fields).
In each of this inputs is validation script in validate event of this.

My question is: How to disable validation of all inputs in form when is form opening (initializing). And start validation of all inputs in event of button click?

Thanks very much.

4 Replies

Avatar

Former Community Member

You cannot stop the events from firing but you can test a condition before runing your code. At initialization is the field empty or does it have a specific value? If not can you set a flag in a field to tell you what state the form is in and then decide from that whether you shodul run validations or not?

Paul

Avatar

Level 2

Thanks for your reply.
But, I have form where is for example input empty (in initialize event).
And I need validate when is user filling the text to input field (for example when is going out from input).
And I need validate all inputs in form, when a push the button "Validate form".

My form validate all inputs by JavaScript in (the best way) validate event.
What are my choices?

I need stop run validate event when is a form opening. And I need run validate when I am filling input fields and pushing validate button on my form.

Thanks.

Avatar

Level 10

Did you try placing the code to check whether the field has value in it before doing the validation?

In Validate event with Java Script as Language:

if(this.rawValue != null && this.rawValue != "") {

     //Place all your validation script inside this enclosed brackets.

}

In Validate event with FormCalc as Language:

if($.rawValue ne null and $.rawValue ne "") then

     //Place all your validation script inside this enclosed brackets.

endif

Thanks

Srini

Avatar

Level 2

Yes it is good idea, but I need also validate input field whether is mandatory.
I know, i can set value property "User Entered - Require". But this is not what I need.
Is some way how ban run all validation events, when is document opening?

For example when I tryed put javaScript code to the root element of document to the initialize event.
xfa.host.validationsEnabled = false;

And then still to the docReady event of root element of document
xfa.host.validationsEnabled = true;

When is validationsEnablet set to the true value, then is start validation of all fields of document, where is some code in validation event.

Why?

Is some other way how to ban start run of all validation events in documnet (form) and enable validation when is document ready and open?

Thanks very much.