I'm Using EmailValidator for Validation:
<mx:EmailValidator id="Email_Validator"
source="{txtEmail}"
property="text" required="false"/>
And My Code is:
var isValidForm:Boolean=true;
var validatorArr:Array = new Array();
validatorArr.push(Email_Validator);
var validatorErrorArray:Array = Validator.validateAll(validatorArr);
isValidForm = validatorErrorArray.length == 0;
if(isValidForm)
{
//.....
}
It is working fine. But I want domain should be "gmail.com" if some other, validation should return false.. How can I achive this?
I think Regular Expressions are usefull.. But I dont Know to use the same in flex?...
If all you are testing for is "gmail.com", you don't need to use regular expressions at all. A simple
if (txtEmail.text.indexOf ("gmail.com") < 0) doStuff();
// index < 0 => address does not contain search string
would be enough.
Nonetheless, ActionScript 3 has the RegExp class to provide regular expression functionality. See this tutorial.