Hello,
I just created a simple form in flash CS3 and trying to validate it. The problem is when I check the script for any error, the message I get is “script contains no errors” but when I run it, the contact form starts flickering. Help please!
Following is the code:
submit_btn.addEventListener(MouseEvent.CLICK, perform);
function perform(ev:MouseEvent):void
{
if (!isValidName(name1.text))
{
error_field.text="Name required";
}
else if (!isValidEmail(email.text))
{
error_field.text="E-mail required";
}
else if (!isValidZip(zip.text))
{
error_field.text="Phone no. required";
}
else if (!isValidZip(num.text))
{
error_field.text="Phone no. required";
}
else if (!isValidPhone(num1.text))
{
error_field.text="Phone no. required";
}
else if (!isValidName(refers.text))
{
error_field.text="Reference required";
}
}
function isValidName(nm:String):Boolean
{
var nameExpression:RegExp = /[a-z]\s[a-z]/i;
return nameExpression.test(nm);
}
function isValidEmail(email:String):Boolean {
var emailExpression:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
return emailExpression.test(email);
}
function isValidZip(zip:String):Boolean
{
var zipExpress:RegExp = /\d{3}/;
return zipExpress.test(zip);
}
function isValidPhone(ph:String):Boolean
{
var phExpress:RegExp = /\d{4}/;
return phExpress.test(ph);
}