# Please help me with the Condition Loop

**URL:** <https://forum.kirupa.com/t/please-help-me-with-the-condition-loop/314768>\
**Category:** flash\
**Created:** [October 8, 2010, 1:00am UTC](https://forum.kirupa.com/t/please-help-me-with-the-condition-loop/314768 "2010-10-08T01:00:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tinale](https://avatars.discourse-cdn.com/v4/letter/t/dbc845/32.png) [@tinale](https://forum.kirupa.com/u/tinale)\
**Post date:** [October 8, 2010, 1:00am UTC](https://forum.kirupa.com/t/please-help-me-with-the-condition-loop/314768/1 "2010-10-08T01:00:01Z")

</div>

I want to create a loop to reject the email addresses that start or end with an @ character, contain multiple @ characters or contain no . (dot) characters. I have a problem with the condition for contain multiple @ characters or contain no . (dot)characters. My conditions don’t run correctly. Please help me. Thank you very much.

```auto

[COLOR=#0070c0][FONT=serif]var address = "me@mock.org";[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif]var i = 0;[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif]var count = 0;[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif]var total =0;[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif]var isValidAddress = false;[/FONT][/COLOR]
 
[COLOR=#0070c0][FONT=serif]while (i< address.length )[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif]{[/FONT][/COLOR]
 
[COLOR=#0070c0][FONT=serif] if (address.charAt(0) == "@" || address.charAt(address.length - 1) == "@" )[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] {[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] trace("first or last character is @. Invalid email address.");[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] break;[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] }[/FONT][/COLOR]
 
[COLOR=#0070c0][FONT=serif] else if (address.charAt(i) != ".")[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] {[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] trace ("it doesn't contain a dot");[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] break;[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] }[/FONT][/COLOR]
 
[COLOR=#0070c0][FONT=serif] else if (address.charAt(i) == "@" )[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] { [/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] count =1; [/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] total +=count;[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] if (total ==1) [/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] {[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] isValidAddress = true;[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] trace("Valid email address.");[/FONT][/COLOR]
 
[COLOR=#0070c0][FONT=serif] }[/FONT][/COLOR]
[COLOR=#0070c0][FONT=serif] trace("Total is " + total);[/FONT][/COLOR]
 
[COLOR=#0070c0][FONT=serif] }[/FONT][/COLOR]
 
[COLOR=#0070c0][FONT=serif] i++;[/FONT][/COLOR]
 
[COLOR=#0070c0][FONT=serif]}[/FONT][/COLOR]
 

```
