c# Validation for login
<p>My script isnt checking the requirement can u help me out with this?
I'm trying to make it run the script before it run the onclick to check if login is right.</p>

<pre><code> &lt;script type="text/javascript"&gt;
        function checkform() {
         var name = document.getElementsByTagName("UserName");
        var pw = document.getElementsByTagName("Password");
            if(name.charAt(0)!='s'){
            document.getElementById("divMessage").innerHTML = "Please insert an S infront";
                    return false;
            if(pw.length&lt; 8 &amp;&amp; pw.length&gt;16){
             document.getElementById("divMessage").innerHTML = "Please key in a longer password";
                    return false;
                    }

        }else{
       return true;
        }
    &lt;/script&gt;



 &lt;asp:Button ID="btnLogin" class="button" runat="server" CommandName="Login" 
      OnClientClick ="return checkform()" onclick="btnLogin_Click"  text="Login" /&gt;  
</code></pre>
