9 Replies Latest reply on Jul 19, 2011 9:40 PM by seeker__

    How to make a submit button that skips validation?

    seeker__

      In a dynamic form with custom validation I need to have two different submit buttons. One to submit form data as is and and other to validate the data first then submit.

       

      How can I create a submit button that skips validation?

       

      Thx

        • 1. Re: How to make a submit button that skips validation?
          pguerett Level 6

          You can''t force the skipping of the validations. You woudl have to create a different means of performing validations by not using the validate event but by calling your validations from your own program when you hit th enon validate submit button.

           

          Make sense?

           

          Paul

          • 2. Re: How to make a submit button that skips validation?
            seeker__ Level 1

            Thx for the reply Paul. I am not calling any validate event of any field. They are being called automatically when the submit button is clicked.

             

            Some of my fields have some function calls under their validate event.  I need to find a way to either not call does funtions when button A is pressed or may be set a global variable to true as soon as the button is pressed? then check for that at validate event of my fields to see if validation needs to be performed.

             

            What do you think of that?

             

            Where is the best place to make declare this global variable and at which event of Button A should I set it to true?

            • 3. Re: How to make a submit button that skips validation?
              pguerett Level 6

              That woudl work fine .....you can use a hidden field to hold your status variable and I woudl use the click event of the button to execute your code. If you have any code on validate events it will be called automatically when you do a regular submit. You would put all of that validate code into a single script or func

              tion and call it from the button click event.

               

              Hope that helps

              Paul

              1 person found this helpful
              • 4. Re: How to make a submit button that skips validation?
                seeker__ Level 1

                I tried that. I can skip my own validation functions but I still need to skip "nullTest" validation too.

                 

                Here is an XML excerpt from one of the fields:

                 

                        <validate nullTest="error">

                                     <message>

                                        <text name="scriptTest">Field X is required</text>

                                        <text name="formatTest">- Form Details-</text>

                                     </message>


                                     <script contentType="application/x-javascript">

                                         //run my validation function here if skipValidationFlag is off

                                    </script>

                     </validate>

                 

                I figured I can change nullTest to "disabled" using javascript. So when my submit button is pressed I have to do this for every single field : !!!


                field.validate.nullTest = "disabled";

                 

                then set them back to "error" so the normal submit button with validation would work.

                 

                So now my question is, how can I loop over all fields that have nullTest="error" ? can I keep track of them in an array?

                • 5. Re: How to make a submit button that skips validation?
                  pguerett Level 6

                  I have a sample that shows how to get back each field on a form ....I use it to lock each field but you can do whatever you want with it.

                  The code is in a function on this form and the function wil lock all fields in a subform that is passed to the function.

                   

                  Paul

                  1 person found this helpful
                  • 6. Re: How to make a submit button that skips validation?
                    seeker__ Level 1

                    The function is very helpful, thx.

                     

                    I just have an issue accessing validate object under the field elements. I can lock all fields using you LockAllFields() I added the following into the loop script:

                     

                    allChildElements.item(j).validate.nullTest = "disabled";

                     

                    In Acrobat's debuger I get an error saying "allChildElements.item(j).validate is undefined". Evey Node must have a validate object as far as I know. Aren't allChildElements.item(j) nodes?

                    • 7. Re: How to make a submit button that skips validation?
                      pguerett Level 6

                      The allChileElements will give you everything under that node (fields, subforms, draws, etc....) Some of those objects do not have a validate property. Thats why there is a further qualification where we are grabbing objects with a specific className of subform or field. If it is a subform then we need to dig deeper into that structure, if it is a field then we can set the validation.

                       

                      Make sense?

                       

                      paul

                      • 8. Re: How to make a submit button that skips validation?
                        seeker__ Level 1

                        I discovered it (in a hardway). I ended up using try { ...}catch(e){} 

                         

                        Now I can disable nulltest for most fields. I say most fields because there could be multiple instances of some fields (in dynamicly generated fields) so I may have 3 previousJobTitle fields. User can add more as needed. Our function does not seem to capture those repatable fields.

                         

                        looking into the reference I am trying to do something like the following the function reaches a subform:

                         

                        currentSubformFieldsNodes = currentElement.resolveNodes("#fields[*]");

                        • 9. Re: How to make a submit button that skips validation?
                          seeker__ Level 1

                          Thx Pual, I solved it using your function.