title: Can Javascript validation and ASP.NET Validators work simultaneously
body: <p>i have two question here</p>
  
  <ul>
  <li><p>i used both javascript validation and ASP.NET Validators ,but .net validators is not working completely,it is showing validation messages but when i click on submit form gets submit</p></li>
  <li><p>another is ,in javascript validation email validation is not working,i have written email validation function in aspx file and rest javascript validation in cs file</p></li>
  </ul>
  
  <p>in email validation when i use getElementById it showing nothing but when i use getElementByName it showing validation message ,even if email is right it shows validation message and form gets submit too</p>
  
  <p>email validation function in aspx file-</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function checkEmail() {
      var email = document.getElementsByName('txtremail');
      var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
      if (!filter.test(email.value)) 
      {
          alert('Please provide a valid email address');
          email.focus;
          return false;
      }
      else {
          return true;
      }
  }
  </code></pre>
  
  <p></p>
  
  <p>submit button -</p>
  
  <pre><code>&lt;asp:ImageButton ID="submitbtn" runat="server"
          ImageUrl="~/images/joinnow.jpg" CssClass="joinbtn" 
      ValidationGroup="join" onclick="submitbtn_Click" OnClientClick="return checkEmail()"/&gt;
  </code></pre>
  
  <p>and in cs file i have used if conditions,because of which i think form gets submit even if email is invalid</p>
  
  <p>cs file code is -</p>
  
  <pre><code> public bool chkpass(string pass, string conpass)
  {
      if (pass.Equals(conpass))
      {
          return true;
      }
      return false;
  }
  protected void submitbtn_Click(object sender, ImageClickEventArgs e)
  {
      if (txtruname.Text != "" &amp;&amp; txtrfname.Text != "" &amp;&amp; txtrpass.Text != "" &amp;&amp; txtremail.Text != "" &amp;&amp; txtrdesc.Text != "")
      {
          if (!chkpass(txtrpass.Text, txtrcnpass.Text))
          {
              Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('password does not match');", true);
          }
          else
          {
              dl.req_username = txtruname.Text;
              DataTable dt = new DataTable();
              dt = bl.reqruiter_uname(dl);
              if (dt.Rows.Count &gt; 0)
              {
                 lblwarning.Text = "username exists";
              }
              else
              {
                  dl.req_fullname = txtrfname.Text;
                  dl.req_username = txtruname.Text;
                  dl.req_password = txtrpass.Text;
                  dl.req_email = txtremail.Text;
                  dl.req_description = txtrdesc.Text;
                  bl.reqruiter_registration(dl);
              }
          }
      }
      else
      {
          Page.ClientScript.RegisterStartupScript(GetType(), "", "alert('please fill all info');", true);
      }
  </code></pre>
  
  <p>so,what should i do to make form to not submit when email is wrong?
  and if possible how can i write email validation in cs file ,so it can satisfy if condition on submit click,thanks</p>