Flash form e-mail validation

  • mtolgao
  • Newbie
  • Newbie
  • mtolgao
  • Posts: 7

Post 3+ Months Ago

Hello,

I was following a tutorial I have found on the web and then came up with this code:
Code: [ Select ]
on (release){
    if (isim == null && eposta == null && mesaj == null) {
        hataisim = "Lütfen isminizi giriniz";
        hataeposta = "Lütfen e-posta adresinizi giriniz";
        hatamesaj = "Lütfen mesajınızı giriniz";
        setTimeout(function() { delete hataisim },2000);
        setTimeout(function() { delete hataeposta },2000);
        setTimeout(function() { delete hatamesaj },2000);
    } else if (isim == null) {
        hataisim = "Lütfen isminizi giriniz";
        setTimeout(function() { delete hataisim },2000);
    } else if (eposta == null) {
        hataeposta = "Lütfen e-posta adresinizi giriniz";
        setTimeout(function() { delete hataeposta },2000);        
    } else if (mesaj == null) {
        hatamesaj = "Lütfen mesajınızı giriniz";
        setTimeout(function() { delete hatamesaj },2000);
    } else if (eposta.indexOf("@") == -1 || eposta.indexOf(".") == -1 || eposta.indexOf("com") == -1 || eposta.indexOf("net") == -1 || eposta.indexOf("org") == -1) {
        hataeposta = "Lütfen geçerli bir adres girin";
        setTimeout(function() { delete hataeposta },2000)
    } else {
    loadVariablesNum("iletisim.php",0,"POST");
    gotoAndPlay("tamam");
    }
  1. on (release){
  2.     if (isim == null && eposta == null && mesaj == null) {
  3.         hataisim = "Lütfen isminizi giriniz";
  4.         hataeposta = "Lütfen e-posta adresinizi giriniz";
  5.         hatamesaj = "Lütfen mesajınızı giriniz";
  6.         setTimeout(function() { delete hataisim },2000);
  7.         setTimeout(function() { delete hataeposta },2000);
  8.         setTimeout(function() { delete hatamesaj },2000);
  9.     } else if (isim == null) {
  10.         hataisim = "Lütfen isminizi giriniz";
  11.         setTimeout(function() { delete hataisim },2000);
  12.     } else if (eposta == null) {
  13.         hataeposta = "Lütfen e-posta adresinizi giriniz";
  14.         setTimeout(function() { delete hataeposta },2000);        
  15.     } else if (mesaj == null) {
  16.         hatamesaj = "Lütfen mesajınızı giriniz";
  17.         setTimeout(function() { delete hatamesaj },2000);
  18.     } else if (eposta.indexOf("@") == -1 || eposta.indexOf(".") == -1 || eposta.indexOf("com") == -1 || eposta.indexOf("net") == -1 || eposta.indexOf("org") == -1) {
  19.         hataeposta = "Lütfen geçerli bir adres girin";
  20.         setTimeout(function() { delete hataeposta },2000)
  21.     } else {
  22.     loadVariablesNum("iletisim.php",0,"POST");
  23.     gotoAndPlay("tamam");
  24.     }


All of it works, except that it doesn't count even my own e-mail .net address as valid. So I googled a bit and found this:

Code: [ Select ]
regExp = "^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"


but I don't know how to integrate this. Can you help me?

Thank you and Best regards,
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

If you're doing your project in AS 2.0 then you should use an actionscript class for regular expressions.
I found this on net, maybe there are others too: http://www.jurjans.lv/flash/RegExp_JLott.zip
If AS 3.0, then just go to adobe site and read the examples:
http://livedocs.adobe.com/flash/9.0/Act ... egExp.html
  • mtolgao
  • Newbie
  • Newbie
  • mtolgao
  • Posts: 7

Post 3+ Months Ago

How do I use that file? I only know that I have to write #include <the name of the file> at the top of my file.

Best regards,
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

use import, not include.
the usage for import is:
import package_path.ClassName;
but in your case, since there is no package path, just use:
Code: [ Select ]
import RegExp;
var objRegeExp = new RegExp("^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$");
trace(objRegeExp.test("mymail@domain.com"));
trace(objRegeExp.test("mymail@fake"));
  1. import RegExp;
  2. var objRegeExp = new RegExp("^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$");
  3. trace(objRegeExp.test("mymail@domain.com"));
  4. trace(objRegeExp.test("mymail@fake"));


for documentation:
http://www.jurjans.lv/flash/RegExp.html

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.