2 Replies Latest reply on Jun 21, 2013 9:21 AM by Transcon Guy

    Validating Emails fields in my Dialog Box

    Transcon Guy Level 1

      Hi all, I want to validate emails in my dialog box. My field are automatically fill by an XML and I want to validate them. I am able to validate them when the user enter a new email but if the user do not enter a new email and hit "OK", there is no validation. Any idea? Thanks!

       

      var submitEmailTo = "client10@somewhere.com\rclient@somewherecom"

      var submitEmailFrom = "currentCVSC@mycompany.com"

      var patt = /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/g;

      var dialog1 = {

          submitEmailTo: "",

          submitEmailFrom: "",

          submitEmailMessage: "",

       

          initialize: function (dialog)

          {

              dialog.load(

              {

                  "emto": submitEmailTo

              });

              dialog.load(

              {

                  "emfr": submitEmailFrom

              });

          },

          commit: function (dialog)

          {

              var results = dialog.store();

              this.submitEmailTo = results["emto"];

              this.submitEmailFrom = results["emfr"];

              this.submitEmailMessage = results["mess"];

          },

          emto: function (dialog)

          {

          var data = dialog.store(["emto"])

          emtoString = data["emto"]

          emtoArray = emtoString.split("\r")

          for (var i=0;i<emtoArray.length;i++)

              {

              if (emtoArray[i].match(patt) == null)

                  {

                      app.alert("Le courriel \"" + emtoArray[i] + "\"ne semble pas valide.", 1, 0, "Validating");

                  }

              }

          },

          description:

          {

              name: "Job Information", // Dialog box title

              align_children: "align_row",

              width: 400,

              height: 200,

              elements: [

              {

                  type: "cluster",

                  name: "Email Information",

                  align_children: "align_right",

                  elements: [

                  {

                      type: "view",

                      align_children: "align_row",

                      elements: [

                      {

                          type: "static_text",

                          name: "From (CVSC): "

                      },

                      {

                          item_id: "emfr",

                          type: "edit_text",

                          alignment: "align_left",

                          width: 400,

                          height: 20

                      }]

                  },

                   {

                      type: "view",

                      align_children: "align_row",

                      elements: [

                      {

                          type: "static_text",

                          name: "To: "

                      },

                      {

                          item_id: "emto",

                          type: "edit_text",

                          multiline: true,

                          alignment: "align_left",

                          width: 400,

                          height: 30

                      }]

                  },

                  {

                      type: "view",

                      align_children: "align_row",

                      elements: [

                      {

                          type: "static_text",

                          name: "mess: "

                      },

                      {

                          item_id: "emto",

                          type: "edit_text",

                          multiline: true,

                          alignment: "align_left",

                          width: 400,

                          height: 70

                      }],

                  },

                  {

                      alignment: "align_right",

                      type: "ok_cancel",

                      ok_name: "Ok",

                      cancel_name: "Cancel"

                  }],

              }],

          }

      }

      app.execDialog(dialog1)

      this.info.submitEmailTo = dialog1.submitEmailTo

      this.info.submitEmailCC = dialog1.submitEmailCC

      this.info.submitEmailMessage = dialog1.submitEmailMessage

        • 1. Re: Validating Emails fields in my Dialog Box
          try67 MVP & Adobe Community Professional

          What does this code has to do with your question?

           

          When a form is populated through an external source, the validation scripts (or any other ones, for that matter) do not trigger.

          What you can do is call a script when the document is opened to validate the values of your fields, and reset them if they're not valid.

          • 2. Re: Validating Emails fields in my Dialog Box
            Transcon Guy Level 1

            Actually this code is  attached to a button action. When my form is opened at first, my fields are populated and all the extra information are send to custom metadata.

             

            The opearator here, will hit a button  and a big dialog box appear with all the job information. You see actually only the email cluster. The idea is to help the operator to  easily build an email with copy and paste. Sometime the emails fields will be filled automatically and sometime the operator will fill them.

             

            The reason I go through a dialog box is I don't want the client to see to much information and the email is sent by a another application.

             

            My first idea was to put a validation script on the "OK" button but it seems not possible to "cancel" this action.