Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add an Email validation to this for flash

Status
Not open for further replies.

Wulfgen

Technical User
Dec 31, 2004
283
US
Hello All,
I have this script in a form I downloaded from "Peopleforfun.com" It is a simple PHP email form and it works just fine - however - the form works regardless of whether it has a valid email address or not! Is there a way to add a validation script to the existing script to make it somewhat more functionable? Code is shown here:

Code:
this.onEnterFrame = function() {
	if (nome.length>0 && address.length>0 && address2.length>0 && email.length>0 && comment.length>0) {
		mc1.onRollOver = function() {
			with (this) {
				colChange = new Color(txt);
				colChange.setRGB(0x6699cc);
				gotoAndStop(2);
			}
		};
		mc1.onRollOut = mc1.onReleaseOutside =function() {
			with (this) {
				gotoAndStop(1);
				colChange = new Color(txt);
				colChange.setRGB(0x1E3F66);
			}
		};
		mc1.onRelease = function() {
			nextFrame();
		};
	}
};
// this check the input text are filled, as you can see the submit button is disable until you fill all the forms
 
Code:
String.prototype.isEmail = function() {
    var i, stringLength, invalidChars;
    stringLength=this.length;
    invalidChars = "*|,\":<>[]{}`';()&$#%";
    for (i=0; i<stringLength; i++) {
        if (invalidChars.indexOf(this.charAt(i)) != -1) {
            return(undefined);
        }
    }//End for loop
    if(this.indexOf("@") == -1) return(undefined);
    if(this.indexOf(".") == -1) return(undefined);
    return(true);
}

usage

emailAddress = "bill"
if(!isEmail.emailAddress){
trace("invalid email");
}
 
Do I simply append this to the existing script? or is there something else? Please forgive my ignorance... :-(
 
add to initial if statement

&&email.isEmail

add the prototype to the main frame code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top