How to check this

How to check whether the visitors’s input of e-mail address is correcet or not and give a msg to the visiotr that the input is invalid.same as http://www.2advanced.com/
please help

[AS]/#####################################/
/* Email - Check | Flash MX | 2002 /
/
Sebastian Wichmann /
/
Michael Holl (Holly) /
/
http://www.flashhilfe.de /
/
#####################################*/

// Email darf nur die folgenden Zeichen enthalten
email_instanz.restrict = “a-zA-Z0-9@._-”;

function email_check() {
if (email.length) {
inhalt = email.split("@");
domain = inhalt[1].split(".");
laenge = domain.length;
return inhalt.length == 2 && inhalt[0].length >= 1 && laenge >= 2 && domain[laenge-2].length >= 3 && domain[laenge-1].length <= 4 && domain[laenge-1].length >= 2 && domain.join().indexOf("_") == -1 ? true : false;
}
return false;
}

// Usage: Button (Textfeld => Vari.: email, Instanz.: email_instanz)
on (release) {
email_check(_root.email) ? trace(“Email is OK!”) : trace(“Email wrong!”);
} [/AS]

Can u explain in details ?
where should i put those scripts in ?
flash or PHP ?
thanks a lot

that’s actionscript, so use in flash;

1.“email_instanz” replace by the instance name of the textfield where email is entered; restrict allows only certain chars/disallows others; script in main timeline keyframe

  1. "function email_check() " is, as the name says, the function called to perform the validation, put in same keyframe as above.
    will return true or false

3.“on (release)” on the submit button (to make things simple, in mx should be in keyframe again, never mind…)
-replace “_root.email” by path & instance of your email input textfield
-replace “trace” actions by what you want to happen in each case…

try, if it doesn’t work, i’ll look at your fla

ps : or did you want one for php?

oh i understand now
but how can i show the output such as “email is ok” to the user?

and i also want to know that how can i check whether the input is a number or not.Thank you very much

are u there eyezberg?
please help
thanks

  1. “how can i show the output such as “email is ok” to the user?”
    in “email_check(_root.email) ? trace(“Email is OK!”) : trace(“Email wrong!”);” replace the traces by: ?feedbacktextfield.text = “Mail ok” : feedbacktextfield.text = “Mail not valid!”
    (the function returns true or false, if true you get the 1st message, else the 2nd
  2. check this:
    http://64.207.155.38/forums/showthread.php?s=&threadid=20960
    (restrict as used there will allow only numbers)

make a fla, post it, i’ll take a look and fix it if needed, but try for yourself first! that’s how you learn, little by little getting to know how the different actions work…