2 Replies Latest reply on Jan 5, 2013 12:14 PM by ChrisG

    Scripted field validation

    ChrisG

      Dear FMP gurus

       

      I am looking for some clever examples of using a script to validate fields. I have a questionnaire with approximately 140 fields. Most of these fields have value lists in the form of check boxes and radio buttons. Some of the fields ask a question like: "Have you ever hurt your knee?" if you answer yes then you must also answer the next "n" fields, else you should leave them empty. My database is built using the session model where the user fills in all the fields and then clicks a save button. It is when the save button is clicked that I want to run a validation script. I do not want to use FM's built in field validation because it validates each time the user leaves the field. I want the user to be able to fill in the entire form without being bothered and then when the save button is clicked, validation takes place. The user still has the choice to cancel if desired. I will also have to use conditional formatting next to each field to show a red asterisk if it is a required field.

      Does anyone have any good ideas for achieving this without becoming to complex.

       

      Thank you

       

      Chris G

        • 1. Re: Scripted field validation
          DavidJondreau

          Instead of 140 fields, you should probably have a separate table for the questions. Actually a table for the Questions and a Response table for a particular's user's questions / answers. The Questions table would have the logic for the validation. A new Questionaire script would generate records in the Response table based on the Questions table.

          • 2. Re: Scripted field validation
            ChrisG

            Thanks David. That sounds really interesting. The way I understand it the question table will have 140 records as opposed to 140 fields in one record. Each question record will have one field for the actual question. There will probably be some kind of an ID field to link all these questions to one questionnaire. When a user is asked to complete a questionnaire, 140 response records will be created with the related question showing up as a label next to the response field. Somehow all of these fields and labels (questions) will have to be displayed on a coherent layout. How would the validation logic work on the question table? Especially when one question will determine the response to any number of answers.

             

            Do I sort of have the idea?