3 Replies Latest reply: Mar 31, 2008 3:21 PM by kglad RSS

    Is it possible to validate an e-mail  or a number.

    INVT Community Member
      I have a fomr that I just got to work recnently with the help of some of one of the sneior memebers but I am concerned becasue the code that I was able to put together deos not really check to see if the email is an email and if teh phone number is a number and well you know the rest.

      I really just need to validate that the email is typed in as an email i.e. name@whatever.com and the number is 111-222-3333 .

      INVT

      Here its the code.
        • 1. Re: Is it possible to validate an e-mail  or a number.
          kglad CommunityMVP
          with all those typos, you should copy and paste some else's code. as3 supports regular expressions so you can use, for example, php email validation code that you convert to as3.

          phone numbers are more tricky depending upon what part of the world, if any, you want to include. but you can also lift someone else's regexp code.
          • 2. Re: Is it possible to validate an e-mail  or a number.
            INVT Community Member
            quote:

            Originally posted by: kglad
            with all those typos, you should copy and paste some else's code. as3 supports regular expressions so you can use, for example, php email validation code that you convert to as3.

            phone numbers are more tricky depending upon what part of the world, if any, you want to include. but you can also lift someone else's regexp code.


            Sorry about the typos. 4 am and no sleep what can I say. The code is from a tutorial and I went through it 5 times before I got it right but I am still learning:).

            I was interested though about using PHP code to convert to AS3. I work with a programmer who is really good at PHP so this will come in very handy. Ild like to get him soem resources about this technique PHP to AS3 any links or threads you can recomend would be appreciated.

            By the way I remade the form using DW validation spry components works well and it did the job. I don't think I want to get that technical with phone # prefexes. I guess what I'm looking for is the same way the DW spry components just checks that it is a number and make sure there are for instance 10 digits.

            Anyway thanks for that information works for me.

            INVT

            • 3. Re: Is it possible to validate an e-mail  or a number.
              kglad CommunityMVP
              if you want to check for a u.s. phone number, you can use the flash string methods to strip extraneous characters and then check string length for 10 characters and then use the Number() function and isNaN() function to see if your 10 characters can resolve to a number.