Need help in javascript
<p>I have two problem in my data entry page: probml 1)Though I am doing client side validation, why pointer is going to code behind page..
I have a text field called amount if that field is empty I am one alert message and focusing on that field. But immidieately control going to code behind page: in this line: 
decimal amount = Convert.ToDecimal(txtAmount.Text);Here I am getting the exception, “Input paramater was not in correct format”
Here is javascript code:</p>

<pre><code>&lt;script type="text/javascript"&gt;
function validate()
{
    var value = document.getElementById("txtAmount").value;
    if(value=="")
    {
    alert("Please enterAmount.");
    document.getElementById("txtAmount").focus();   
    return false;        
    }
    else
    {
     return  true;     
     }
}
&lt;/script&gt;
&lt;asp:Button ID="btnSave" runat="server" Text="Save" Width="64px" Font-Bold="true" OnClientClick="validate()" onclick="btnSave_Click"/&gt;
</code></pre>

<p>Prblm2: While I am entering duplicate values I am expecting the message like “This id already exists, please try with another id”, but I am getitng the excetpion like primary key conflict……… Here is code for that..</p>

<pre><code>        if (!Page.IsValid)
            return;
        int sum = 0;
        ContactPersonBO contactpersonbo = new ContactPersonBO();
        string personid = txtPersonid.Text;
        decimal amount = Convert.ToDecimal(txtAmount.Text);
        try
        {

            contactpersonbo.PersonID = personid;            
            contactpersonbo.Amount = amount;         

            sum = ontactpersonbo.InsertPerson();
            if (sum &gt; 0)
            {
                lblMessage.Text = "person has been succesfully added.”;              

            }
            else
            {

                lblMessage.Text = "This person already exists, please try with otherid”;
            }

        }
        catch (Exception ex)
        {
            lblMessage.Text = ex.Message.ToString();
        }
</code></pre>

<p>Note: Here control is never coming to this part:   </p>

<pre><code>    else
    {

        lblMessage.Text = "This person already exists, please try with otherid”;
    }
</code></pre>
