title: how to prevent postback by javascript
body: <p><strong>actually this code is working well in firefox mozilla but it's not working in IE8</strong>            </p>
  
  <pre><code>&lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="btnPrimary" OnClientClick="return doSubmit('this');"
          OnClick="btnSubmit_Click" /&gt;
        &lt;script type="text/javascript"&gt;
             function doSubmit() 
             {
              var ansLength = oDOM.body.innerText.trim().length;
              if (ansLength == 0 &amp;&amp; smielyPresent == -1) 
                {
                alert("you cannot submit blank answer");
                return false;
                }
             }
      &lt;/script&gt;
  
       protected void btnSubmit_Click(object sender, EventArgs e)
      {
        // i am doing some stuff
      }
  </code></pre>
  
  <p>here i want to prevent postback when <code>answerlength == 0 ;</code> 
  but when <code>answer length ==0</code> then it alert  <code>alert("u can't submit blank answer")</code> message and postback to server io want to prevent it how i do ?</p>