title: Check for valid email before running remaining javascript
body: <p>I have a textbox where the user is required to insert a valid email address.</p>
  
  <p>When the user submits a valid email address a loading graphic appears while the data is posted back.</p>
  
  <p>The code below works fine for showing the loading graphic but it does not check that the email address is valid first. Can anyone help out?</p>
  
  <pre><code>$('#btnEmail1Submit').live ("click", function() {
     $('&lt;div class="submitBg"&gt;&lt;/div&gt;').appendTo(".emailEditContainer");
     $('&lt;div class="submitLoadingCont"&gt;&lt;img class="submitLoading" src="images/mypreferences/loading.gif" width="50" height="50" /&gt;&lt;/div&gt;').appendTo(".emailEditContainer");
  });
  </code></pre>
  
  <p>I am thinking that I need to put an if statement around the function that is run on click - so something like:</p>
  
  <pre><code>$('#btnEmail1Submit').live ("click", function() {
    if(emailvalid == true) {   
      $('&lt;div class="submitBg"&gt;&lt;/div&gt;').appendTo(".emailEditContainer");
      $('&lt;div class="submitLoadingCont"&gt;&lt;img class="submitLoading" src="images/mypreferences/loading.gif" width="50" height="50" /&gt;&lt;/div&gt;').appendTo(".emailEditContainer");
    }
  });
  </code></pre>
  
  <p>I am using asp.net email validation - it looks something like this:</p>
  
  <pre><code>&lt;asp:RegularExpressionValidator Display="Dynamic" ValidationGroup="PrimarySubmit" ID="RegularExpressionValidator1" runat="server" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="tbEmail1" ErrorMessage="Invalid email address - " /&gt;
  </code></pre>