3 Replies Latest reply on May 9, 2006 1:36 PM by Newsgroup_User

    Validate email text string Field using a 'pattern' match

    Level 7
      Hi,

      Can anyone point me to how to validate a text string so that it is a
      correctly formatted email address, like you do in JavaScript and PHP using
      regular expressions / pattern matching.

      I'm making a simple form, but I want validate email addresses, e.g.

      Xxx @ xxx . Xxx

      James @ weburl . Com

      I'd also like to validate:

      the phone field as numbers only
      the name field as text only
      and..
      the number of chars in a field

      Thank you.

      James R.

        • 1. Re: Validate email text string Field using a 'pattern' match
          Level 7
          JRP Media wrote:
          > Can anyone point me to how to validate a text string so that it is a
          > correctly formatted email address, like you do in JavaScript and PHP
          > using regular expressions / pattern matching.

          If you're using MX2004 then you could use JavaScript syntax which has regex
          stuff built in, else there's the free PRegEx xtra from http://openxtras.org/
          (the one download contains both Mac and PC xtras).

          Andrew


          • 2. Re: Validate email text string Field using a 'pattern' match
            Level 7
            Thank you Andrew,

            I am on Director MX v9.0

            I'm looking at the plug-in now...

            James R.


            On 9/5/06 09:28, in article e3pjrr$b0o$1@forums.macromedia.com, "Andrew
            Morton" <akm@in-press.co.uk.invalid> wrote:

            > JRP Media wrote:
            >> Can anyone point me to how to validate a text string so that it is a
            >> correctly formatted email address, like you do in JavaScript and PHP
            >> using regular expressions / pattern matching.
            >
            > If you're using MX2004 then you could use JavaScript syntax which has regex
            > stuff built in, else there's the free PRegEx xtra from http://openxtras.org/
            > (the one download contains both Mac and PC xtras).
            >
            > Andrew
            >
            >

            • 3. Re: Validate email text string Field using a 'pattern' match
              Level 7
              > the phone field as numbers only
              > the name field as text only
              > and..
              > the number of chars in a field

              For these 3 you don't need a Regular Expression. The first 2 are a
              matter of only permitting certain characters to be entered, and the last
              is restricting input based on the current character count (if I
              understand correctly)
              Here's a behavior that will restrict entry to numbers only. The same can
              be done for alpha characters by altering the list of allowed character
              codes:
              --
              property myMember
              property myAllowedCodes

              on beginSprite me
              myMember = sprite(me.spriteNum).member
              myAllowedCodes =
              [18,19,20,21,22,23,25,26,28,29,82,83,84,85,86,87,88,89,91,92,51,117,123,124]
              end

              on keyDown me
              kc = the keyCode
              if myAllowedCodes.getPos( kc ) then
              pass
              else if kc = 115 then
              -- HOME
              myMember.selection = [0,0]
              stopEvent
              else if kc = 119 then
              -- END
              nChars = myMember.char.count
              myMember.selection = [nChars, nChars]
              stopEvent
              else
              stopEvent
              end if
              end