Sooner or later you will face with the small quest of validating an email address for your flash application. The following script is a basic script and should not be used for websites that relay heavily on the email address is being requested (shopping carts, credit card transactions and so forth)
[as]function isValidEmail(e) {
if (e.indexOf(“@”) != -1 && ( e.indexOf(“.”) > e.indexOf(“@”) ) ){
trace(“success”);
}else{
trace(“error”);
}
}
//Test
isValidEmail(“test@test.com”);
[/as]
very good one but what if you got an email like me.u@gmail.com ?
it will return it false …
any idea ?
How about like this ???
if (e.indexOf(“@”) != -1 && ( e.lastIndexOf(“.”) > e.indexOf(“@”) ) ) {
trace(“success”);
}else{
trace(“error”);
}
// a minimum a@a.us is require
if ((emailString.indexOf("@") > 0) &&
(emailString.lastIndexOf(".") > (emailString.indexOf("@") + 1)) &&
(emailString.lastIndexOf(".")
// minimum a@a.us
if ((e.indexOf("@") > 0) &&
(e.lastIndexOf(".") > (e.indexOf("@") + 1)) &&
(e.lastIndexOf(".")
Hello,
i want email validation with flash action script which i have
apply here the code :
validate_btn.onRelease = function() {
indexOfAt = email.text.indexOf(“@”);
lastIndexOfDot = email.text.lastIndexOf(“.”);
if (indexOfAt != -1 && lastIndexOfDot != -1) {
if (lastIndexOfDot
[code]
function is_valid_email(email:String):Boolean {
var emailRgx:RegExp = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
///^[a-zA-Z0-9][-._a-zA-Z0-9]*@([a-zA-Z0-9]*.)+[a-zA-Z]{2,6}$/;
trace(emailRgx.test(email));
return emailRgx.test(email);
}
is_valid_email(“c@j.co”);
[/code]
Do we need to inport any thing like – import RegExp; for the above code to work?