eMail flash validator
// Button Listener
submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);
// Button Click Function
function ValidateAndSend(event:MouseEvent):void{
if (validateEmailAddress(email_txt.text) == false) {
status_txt.text = "Please enter a VALID email address.";
} else {
status_txt.text = "Sending to PHP now, Email is valid.";
}
}
// Validate Email Function
function validateEmailAddress(emailString:String):Boolean {
var myRegEx:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
var myResult:Object = myRegEx.exec(emailString);
if(myResult == null) {
return false;
}
return true;
}
// The RegExp class includes the following methods: test() and exec()
// For more information, see [Methods for using regular expressions with strings] in AS3 help file