|
-
KoolMoves Moderator
email validation
Someone ask me if we could validate an email before submiting to the server script on an 3dfa form.... So here we go
PHP Code:
errormsg=""//clear the error message if there is one
dot=email.indexOf(".",0)//find the dot
if (dot<1){//No dot?
errormsg+="No dot\n"
}
else{//there is a dot but must have at least two chars after it
ext=email.substr(dot+1)
if (ext.length<2 || ext.length>3){
errormsg+="Invalid Domain\n"
}
}
theat=email.indexOf("@",0)//find the at
if (theat<0){//no at?
errormsg+="No @ \n"
}
else{//found at but is there at least one character in front of it?
name=email.substr(0,theat)
if (name.length<1){
errormsg+="must have name\n"
}
}
trace (errormsg)
Example
Source file
-
Bret, damn you!
I was going to help...you beat me to it again.
Good work.
I guess that's why they referred to you...(You know who I'm talking about.)
-
Re: email validation
Originally posted by blanius
Someone ask me if we could validate an email before submiting to the server script on an 3dfa form.... So here we go
PHP Code:
errormsg=""//clear the error message if there is one
dot=email.indexOf(".",0)//find the dot
if (dot<1){//No dot?
errormsg+="No dot\n"
}
else{//there is a dot but must have at least two chars after it
ext=email.substr(dot+1)
if (ext.length<2 || ext.length>3){
errormsg+="Invalid Domain\n"
}
}
theat=email.indexOf("@",0)//find the at
if (theat<0){//no at?
errormsg+="No @ \n"
}
else{//found at but is there at least one character in front of it?
name=email.substr(0,theat)
if (name.length<1){
errormsg+="must have name\n"
}
}
trace (errormsg)
Example
Source file
Bret,
email is the variable assigned to that edit box right?
-
KoolMoves Moderator
yes email is the variable in the editbox...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|