# If ... statement doesn't execute e-mail validation

**URL:** https://forum.kirupa.com/t/if-statement-doesnt-execute-e-mail-validation/172327
**Category:** Uncategorized
**Created:** [December 13, 2005, 11:38am UTC](https://forum.kirupa.com/t/if-statement-doesnt-execute-e-mail-validation/172327 "2005-12-13T11:38:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mariajose](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mariajose](https://forum.kirupa.com/u/mariajose)
#### Post date: [December 13, 2005, 11:38am UTC](https://forum.kirupa.com/t/if-statement-doesnt-execute-e-mail-validation/172327/1 "2005-12-13T11:38:27Z")

</div>

Hi everybogy!  
I have some code for validating e-mail data before it is send. I have including code from Bassem Bouguerra [www.sub-science.com](http://www.sub-science.com) which uses the \ ***WebServiceConnector** \*and deals with imaginary user’s emails. The code validates my 3 fields correctly. The problem is that the last if …statement doesn’t execute despite that the data is correct and my **ok** and \*\*result \*\*variables are true. It is driving my mental. Any clues from anybody? Thanks.

stop();  
import mx.services.\*;  
\_lv = new LoadVars();  
\_lv.onLoad = function() {  
if (!this.faultCode) {  
gotoAndPlay(“success”);

} else {  
gotoAndPlay(“failed”);  
};  
};  
send.onPress = function() {  
response.text = ‘’;  
var ok = true;  
var test:Number = 0;

var checkEmailService = new mx.services.WebService(“[http://www.webservicex.net/ValidateEmail.asmx?WSDL](http://www.webservicex.net/ValidateEmail.asmx?WSDL)”);

if (message.text == ‘’) {  
response.text = “Por favor, introduce un mensaje.”;  
ok = false;  
} else \_lv.message = message.text;

if (email.text == ‘’ || email.text.indexOf(’@’) == -1) {  
response.text = “Por favor, introduce tu e-mail.”;  
ok = false;  
}  
else {  
do {

checkEmailResultOb = checkEmailService.IsValidEmail(email.text);  
checkEmailService.onLoad = trace(“loading”);

checkEmailResultOb.onResult = function(result) {  
trace("the email is " +result);

if (result) {  
\_lv.email = email.text;  
test++;  
ok = true;  
trace(ok);  
trace(result);

}  
else {  
response.text = “Por favor, introduce un e-mail VALIDO.”;  
email.text = ‘’;  
ok = false;  
test = 0;  
trace(result);  
};

};

} while (test = 0);  
};

checkEmailResultOb.onFault = function(fault) {  
trace(fault.faultCode+"," +fault.faultstring);  
if (fault) gotoAndPlay(“failed”);  
};

if (fname.text == ‘’) {  
response.text = “Por favor, introduce tu nombre.”;  
ok = false;  
} else \_lv.fname = fname.text;

if (ok) {  
if (result) {  
response.text = “Enviando e-mail…”;  
\_lv.sendAndLoad(“contactmail.asp”, \_lv, “POST”);  
};  
};

};
