Textfield Validation

I need to validate 3 of 4 textfields in my form. I knwo how to validate a regular text field. I am using the following code.

on(release){
if(!name.length){
status=“Please Enter Your Name”;
}
}

**status=my status textfield.

Now I am not too sure on how to do it for an email. I need the email to contain “@” and “.”

Now only if all these are true the I want it to go to my email. So I need some help with finishing my if statements.

Thanks Guys.

try this


on (release){
	check1 = false;
	check2 = false;
	for (i=0; i<_root.email.length; i++){
		currentChar = _root.email.charAt(i);
		if (currentChar == '@'){
			check1 = true;
		}
		if (check1 == true && currentChar == '.'){
			check2 = true;
		}
	}
	if (check2 == true){
		_root.statusfield = "valid e-mail";
	} else {
		_root.statusfield = "invalid e-mail";
	}
}

I used _root.email as the variable for the input field and changed the status variable to statusfield. Status is a keyword in flash and will cause problems if you try to refer to it using _root.

ok great. thanks. this is def a new way of doing this for me. ill give it a go

:slight_smile:

happy flashing

hey man this script isnt working for me?

are your variables for e-mail and status targeted correctly?

Can’t really help you with why it isn’t working without more information, you may try running the debugger and looking at the variables to try to figure out what is wrong.