Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Validating Emails fields in my Dialog Box

$
0
0

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


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>