I'm validating it using actionscript.
When I try to submit a blank one the validation works fine. So I don't know how I'm receiving all these blank emails?
This code checks that the email address they are providing is in the correct format:
class EmailValidation
{
var errorCode;
function EmailValidation ()
{
errorCode = 0;
}
function init (inp)
{
errorCode = 0;
var specialChar = ["*", ",", ";", ":", "/", "(", ")", "[", "]", "}", "{", "&", "$", "!", "%", "^", "~", "<", ">", "#", " ", "|", "+", "`", "'", "?", chr (92), chr (34)];
if ((inp.length < 6) || (inp.indexOf ("@") <= 0) || (inp.indexOf ("@") != inp.lastIndexOf ("@")) || (inp.lastIndexOf (".") < inp.indexOf ("@")) || ((inp.lastIndexOf (".") + 3) > inp.length) || inp.indexOf (".") <= 0) {
errorCode = 101;
}
if (errorCode == 0) {
checkChar (inp, specialChar);
}
}
function checkChar (inp, specialChar)
{
for (var i = 0; i < specialChar.length; i++) {
if (inp.indexOf (specialChar[i]) >= 0) {
errorCode = 102;
break;
}
}
if (errorCode == 0) {
checkDot (inp);
}
}
function checkDot (inp)
{
var dots = 0;
var len = inp.length;
for (var i = 0; i < len; i++) {
var getStr = inp.substring (i, i + 1);
if (getStr == "." or getStr == "@") {
dots++;
} else {
dots = 0;
}
if (dots == 2) {
errorCode = 103;
break;
}
}
}
function onResultMe (email, info)
{
init (email);
if (info == true) {
switch (errorCode) {
case 101 :
return ("Invalid Email Id");
break;
case 102 :
return ("Special characters not allowed");
break;
case 103 :
return ("Dots appeared in sequence");
break;
case 0 :
return ("Correct Email ID");
break;
}
} else {
return (errorCode);
}
}
}
This validates all of the flash form's input fields
function validation ()
{
var o = owner;
if (o.name_tf.text.length < 1) {
error = 'Please enter your name';
o.showMistake (o.name_tf._y + 10);
Selection.setFocus (o.name_tf);
} else if (o.company_tf.text.length < 1) {
error = 'Please enter your company name';
o.showMistake (o.company_tf._y + 10);
Selection.setFocus (o.company_tf);
} else if (email.onResultMe (o.email_tf.text, false) != 0) {
error = 'Please enter a valid email id';
o.showMistake (o.email_tf._y + 10);
Selection.setFocus (o.email_tf);
} else if (o.phone_tf.text.length < 1) {
error = 'Please enter your phone number';
o.showMistake (o.phone_tf._y + 10);
Selection.setFocus (o.phone_tf);
} else if (o.comment_tf.text.length < 1) {
error = 'Please enter your comments';
o.showMistake (o.comment_tf._y + 10);
Selection.setFocus (o.comment_tf);
} else if (_option == undefined) {
error = 'Oops! no location selected';
o.showMistake (o.countyCOMBO._y + 10);
} else {
error = '';
sendFeedback ();
}
updateResult ();
}
This is the send function using the php
[CODE]function sendFeedback ()
{
var o = owner;
php.owner = this;
php.name = o.name_tf.htmlText;
php.company = o.company_tf.htmlText;
php.email = o.email_tf.htmlText;
php.phone = o.phone_tf.htmlText;
php.comments = o.comment_tf.htmlText;
// option is the selected combo index
php.county = o.countyCOMBO.dataProvider[option];
o.phpvars.text = "";
for (var i in php) {
if (typeof (php[i]) == "string") {
o.phpvars.text += "$" + i + " --> " + php[i] + "\n";
}
}
error = 'sending...';
php.sendAndLoad ("http://www.tees.me.uk/BookNew/feedback.php", php, "POST");
php.onLoad = reply;
}
function reply ()
{
owner.error = "Thank you for your time. A member of our sales team will contact you shortly.";
owner.updateResult ();
}
function updateResult ()
{
showResult.text = error.toUpperCase ();
}
}[/CODE]